Askr documentation
Generated API snapshot

@askrjs/ui/button

Exports from the declarations published in @askrjs/ui. Signatures reflect the published artifact.

Exports

This entrypoint publishes 9 exports. Use the anchored symbol rows for direct links. Type-only exports are labeled separately from runtime values.

Buttontype

Button: { (props: ButtonNativeProps): JSX.Element; (props: ButtonAsChildProps): JSX.Element; }

Headless Button component ## Responsibilities - Compose pressable foundation for interaction behavior - Enforce type="button" default to prevent accidental form submission - Forward props and refs to native button or child element ## Non-Responsibilities (delegated to pressable foundation) - Keyboard event handling (Enter/Space) - Pointer event handling - Disabled state enforcement - ARIA attribute application ## Invariants - MUST NOT contain any event handler logic - MUST NOT check disabled prop directly - MUST use pressable() for ALL interaction behavior - MUST use mergeProps() for ALL prop composition Renders the button part of button. Supports polymorphic rendering via asChild.

Native button (prevents accidental submit)
```tsx
<Button onPress={handleSave}>Save</Button>
```
Explicit form submission
```tsx
<Button type="submit" onPress={handleSubmit}>Submit</Button>
```
Polymorphic rendering (asChild)
```tsx
<Button asChild onPress={handleNav}>
<a href="/home">Home</a>
</Button>
```

ButtonAsChildPropstype

ButtonAsChildProps: ButtonOwnProps & {
  asChild: true;
  children: ButtonAsChildElement;
  ref?: Ref<Element>;
  type?: never;
}

Props when rendering with asChild (polymorphic)

asChild
asChild: true;
children
children: ButtonAsChildElement;
disabled
disabled?: boolean | undefined;
onPress
onPress?: ((e: PressEvent) => void) | undefined;
ref
ref?: Ref<Element>;
size
size?: ButtonSize | undefined;
type
type?: undefined;
variant
variant?: ButtonVariant | undefined;
width
width?: ButtonWidth | undefined;

ButtonNativePropstype

ButtonNativeProps: Omit<JSX.IntrinsicElements['button'], 'children' | 'onClick' | 'disabled' | 'type' | 'ref'> & ButtonOwnProps & {
  asChild?: false;
  ref?: Ref<HTMLButtonElement>;
  type?: 'button' | 'submit' | 'reset';
}

Props when rendering as native <button>

asChild
asChild?: false | undefined;
children
children?: unknown;
disabled
disabled?: boolean | undefined;
onPress
onPress?: ((e: PressEvent) => void) | undefined;
ref
ref?: Ref<HTMLButtonElement>;
size
size?: ButtonSize | undefined;
type
type?: "button" | "submit" | "reset" | undefined;
variant
variant?: ButtonVariant | undefined;
width
width?: ButtonWidth | undefined;

ButtonOwnPropstype

ButtonOwnProps: {
  children?: unknown;
  onPress?: (e: PressEvent) => void;
  disabled?: boolean;
  variant?: ButtonVariant;
  size?: ButtonSize;
  width?: ButtonWidth;
}

Core Button props shared across all variants

children
children?: unknown;
disabled
disabled?: boolean | undefined;
onPress
onPress?: ((e: PressEvent) => void) | undefined;
size
size?: ButtonSize | undefined;
variant
variant?: ButtonVariant | undefined;
width
width?: ButtonWidth | undefined;

ButtonPropstype

ButtonProps: ButtonNativeProps | ButtonAsChildProps

Union of all Button prop variants

asChild
asChild?: boolean | undefined;
children
children?: unknown;
disabled
disabled?: boolean | undefined;
onPress
onPress?: ((e: PressEvent) => void) | undefined;
ref
ref?: ((value: Element | null) => void) | { current: Element | null; } | ((value: HTMLButtonElement | null) => void) | { current: HTMLButtonElement | null; } | null | undefined;
size
size?: ButtonSize | undefined;
type
type?: "button" | "submit" | "reset" | undefined;
variant
variant?: ButtonVariant | undefined;
width
width?: ButtonWidth | undefined;

ButtonSizetype

ButtonSize: 'xs' | 'sm' | 'md' | 'lg' | 'icon' | 'icon-xs' | 'icon-sm' | 'icon-lg'

Button Size.

ButtonVarianttype

ButtonVariant: 'default' | 'primary' | 'secondary' | 'outline' | 'ghost' | 'destructive' | 'link'

Button Variant.

ButtonWidthtype

ButtonWidth: 'auto' | 'full'

Button Width.