> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# 

# Button

A headless Button component for ReactLynx. It provides press state tracking (`active`) and render props for custom styling.
:::info

You can check the [source code](https://github.com/lynx-family/lynx-ui/tree/main/packages/lynx-ui-button) to understand how it works, and you're welcome to submit MRs to enhance its capabilities.

:::

## Basic Usage


**This is an example below: lynx-ui-button**

**Entry:** `Basic`
**Bundle:** `dist/ButtonBasic.lynx.bundle` | Web: `dist/ButtonBasic.web.bundle`

```tsx {19-27,29-34}
// Copyright 2026 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { root } from '@lynx-js/react'

import { Button } from '@lynx-js/lynx-ui'
import { clsx } from 'clsx'

import { Heart } from '../shared/Heart'

import './index.css'

function App() {
  return (
    <view className='demo-container lunaris-dark luna-gradient-rose'>
      <view className='demo-canvas'>
        {/* Usage 1: render props to read `active` state and toggle `.active` for styling */}
        <Button onClick={() => console.info('clicked')} className='button-root'>
          {({ active = false }) => (
            <view className={clsx('button', { 'active': active })}>
              <text className='button-text'>
                Button
              </text>
            </view>
          )}
        </Button>
        {/* Usage 2: regular children; styles rely on the primitives-injected `ui-active` state class */}
        <Button className='button'>
          <Heart />
          <text className='button-text'>
            Button
          </text>
        </Button>
      </view>
    </view>
  )
}
root.render(<App />)
export default App

```



## Structure


```tsx
<Button>
  {/* Your content */}
</Button>
```

## Component API \{#api}

### Button \{#api-button}

The root component of the Button, containing all of its child components.




### State-based styling & rendering

This component exposes runtime states through one or both of the following channels. The table lists only the channels available for each state:

- **UI variant class** — when supported, a class like `ui-<state>` is toggled on the corresponding component node for selectors such as `.ui-<state> { ... }`.
- **Render-prop field** — when supported and `children` is a function, the state is passed in via `children({ <state>: boolean, ... })` for runtime-driven rendering.


UI variants applied by Button based on its render state.


| Class Name | Render Prop | Type | Description |
| --- | --- | --- | --- |
| Class Nameui-active | Render Prop`active` | Type`boolean` | DescriptionWhether the button is currently being pressed (and not disabled).
Applied when `status.active` is true. |
| Class Nameui-disabled | Render Prop`disabled` | Type`boolean` | DescriptionWhether the button is disabled.
Applied when `status.disabled` is true. |

