Lynx/Modules/HeroUI/Button
@sigx/lynx-heroui · Beta · Component library

Button#

Pressable action button with HeroUI fill variants, semantic colors, sizes, and built-in loading/disabled handling.

Import#

TSX
import { Button } from '@sigx/lynx-heroui';

Basic Usage#

Button wraps a Pressable from @sigx/lynx-gestures, so it ships native press feedback (scale + opacity) out of the box. The button label goes in the default slot, and you listen for taps with onPress:

TSX
import { component } from '@sigx/lynx';
import { Button, Text } from '@sigx/lynx-heroui';

export const Demo = component(({ signal }) => {
  const state = signal({ count: 0 });

  return () => (
    <Button color="primary" onPress={() => state.count++}>
      <Text>Pressed {state.count} times</Text>
    </Button>
  );
});

Variants#

variant controls the fill style. It mirrors upstream HeroUI: solid (the default), bordered, flat, and ghost. Combine it with any semantic color:

TSX
import { component } from '@sigx/lynx';
import { Button, Text, Col } from '@sigx/lynx-heroui';

export const Variants = component(() => {
  return () => (
    <Col gap="3">
      <Button color="primary" variant="solid">
        <Text>Solid</Text>
      </Button>
      <Button color="primary" variant="bordered">
        <Text>Bordered</Text>
      </Button>
      <Button color="primary" variant="flat">
        <Text>Flat</Text>
      </Button>
      <Button color="primary" variant="ghost">
        <Text>Ghost</Text>
      </Button>
    </Col>
  );
});

Sizes, States, and Layout#

size accepts the sm / md / lg subset of the shared size scale (md is the default). Setting disabled or loading makes the button non-interactive and applies disabled styling, while block stretches it to fill its container:

TSX
import { component } from '@sigx/lynx';
import { Button, Text, Col } from '@sigx/lynx-heroui';

export const States = component(() => {
  return () => (
    <Col gap="3">
      <Button color="success" size="sm">
        <Text>Small</Text>
      </Button>
      <Button color="success" size="lg">
        <Text>Large</Text>
      </Button>
      <Button color="error" disabled>
        <Text>Disabled</Text>
      </Button>
      <Button color="primary" loading>
        <Text>Loading</Text>
      </Button>
      <Button color="primary" block>
        <Text>Full width</Text>
      </Button>
    </Col>
  );
});

Props#

PropTypeDefaultDescription
color'primary' | 'secondary' | 'accent' | 'neutral' | 'info' | 'success' | 'warning' | 'error''neutral'Semantic color of the button.
variant'solid' | 'bordered' | 'flat' | 'ghost''solid'HeroUI fill style.
size'sm' | 'md' | 'lg''md'Button size on the shared scale.
disabledbooleanfalseDisables the button (non-interactive + disabled styling).
loadingbooleanfalseMarks the button as busy; behaves the same as disabled (non-interactive + disabled styling).
blockbooleanfalseStretches the button to fill its container width.
classstring-Extra CSS classes appended after the computed ones.
accessibility-elementboolean-Forwarded to the host Pressable view; marks the node as an accessibility element.
accessibility-labelstring-Forwarded accessibility label for screen readers.
accessibility-rolestring-Forwarded accessibility role.
accessibility-traitstring-Forwarded accessibility trait.
accessibility-statusstring-Forwarded accessibility status.

Slots#

SlotDescription
defaultButton content (label, icons, etc.).

Events#

EventTypeDescription
onPress() => voidFired when the button is pressed. Suppressed while disabled or loading.