mirror of
https://github.com/hanzoai/gui.git
synced 2026-10-25 02:31:41 +00:00
Both old names are owned by a different npm account (artemis-prime), so publishing them returns 403 — which is how this surfaced: the 8.0.0 run shipped @hanzogui/logo and @hanzogui/demos depending on [email protected], a version that cannot be published and therefore does not exist. Those two were uninstallable. @hanzo/gui and @hanzogui/* are ours, so the framework now carries the name it is imported by everywhere downstream, and the loader moves under the scope we control. The rewrite is limited to package references. `DEBUG?.startsWith('hanzogui')` is a log-namespace filter and join(dir, 'hanzogui') is a path — rewriting either would change behaviour, so both are untouched. Co-authored-by: Hanzo Dev <[email protected]>
148 lines
3.1 KiB
Plaintext
148 lines
3.1 KiB
Plaintext
---
|
|
title: Checkbox
|
|
description: A simple checkbox component
|
|
name: checkbox
|
|
component: Checkbox
|
|
package: checkbox
|
|
demoName: Checkbox
|
|
---
|
|
|
|
# Checkbox
|
|
|
|
<Description>Use in forms to toggle between two states.</Description>
|
|
|
|
<HeroContainer>
|
|
<CheckboxDemo />
|
|
</HeroContainer>
|
|
|
|
```tsx hero template=Checkbox
|
|
|
|
```
|
|
|
|
<Highlights
|
|
features={[
|
|
`Supports indeterminate state.`,
|
|
`Accessible, easy to compose and customize.`,
|
|
`Sizable & works controlled or uncontrolled.`,
|
|
`Ability to opt-out to native checkbox on web.`,
|
|
]}
|
|
/>
|
|
|
|
## Installation
|
|
|
|
Checkbox is already installed in `hanzogui`, or you can install it independently:
|
|
|
|
```bash
|
|
npm install @hanzogui/checkbox
|
|
```
|
|
|
|
## Usage
|
|
|
|
```tsx
|
|
import { Check } from '@hanzogui/lucide-icons-2'
|
|
import { Checkbox } from '@hanzo/gui'
|
|
|
|
export default () => (
|
|
<Checkbox size="$4">
|
|
<Checkbox.Indicator>
|
|
<Check />
|
|
</Checkbox.Indicator>
|
|
</Checkbox>
|
|
)
|
|
```
|
|
|
|
## API Reference
|
|
|
|
### Checkbox
|
|
|
|
`Checkbox` extend ThemeableStack inheriting all the [props](/docs/components/stacks#themeablestack), plus:
|
|
|
|
<PropsTable
|
|
data={[
|
|
{
|
|
name: 'labeledBy',
|
|
type: 'string',
|
|
description: `Set aria-labeled-by.`,
|
|
},
|
|
{
|
|
name: 'name',
|
|
type: 'string',
|
|
description: `Equivalent to input name.`,
|
|
},
|
|
{
|
|
name: 'value',
|
|
type: 'string',
|
|
description: `Give it a value (for use in HTML forms).`,
|
|
},
|
|
{
|
|
name: 'checked',
|
|
type: 'boolean',
|
|
description: `Control the input.`,
|
|
},
|
|
{
|
|
name: 'defaultChecked',
|
|
type: 'boolean',
|
|
description: `Uncontrolled default value.`,
|
|
},
|
|
{
|
|
name: 'required',
|
|
type: 'boolean',
|
|
description: `Sets aria-required.`,
|
|
},
|
|
{
|
|
name: 'native',
|
|
type: 'boolean',
|
|
description: `Renders native checkbox input on web.`,
|
|
default: false,
|
|
},
|
|
{
|
|
name: 'onCheckedChange',
|
|
type: '(checked: boolean | "indeterminate") => void',
|
|
description: 'Callback that fires when the checkbox state is changed.',
|
|
},
|
|
{
|
|
name: 'sizeAdjust',
|
|
type: 'number',
|
|
description: `Adjust the checkbox size scaling by this number.`,
|
|
},
|
|
{
|
|
name: 'scaleIcon',
|
|
type: 'number',
|
|
description: `Scale the indicator icon more than usual by this number.`,
|
|
},
|
|
{
|
|
name: 'scaleSize',
|
|
type: 'number',
|
|
default: '0.5',
|
|
description: `The Gui size tokens should map to the height of a button at any given step. This means you want somewhat smaller checkboxes typically.`,
|
|
},
|
|
{
|
|
name: 'unstyled',
|
|
required: false,
|
|
type: `boolean`,
|
|
description: `Removes all default Gui styles.`,
|
|
},
|
|
]}
|
|
/>
|
|
|
|
### Checkbox.Indicator
|
|
|
|
`Checkbox.Indicator` extend ThemeableStack inheriting all the [props](/docs/components/stacks#themeablestack), plus:
|
|
|
|
<PropsTable
|
|
data={[
|
|
{
|
|
name: 'forceMount',
|
|
required: false,
|
|
type: `boolean`,
|
|
description: `Used to force mounting when more control is needed.`,
|
|
},
|
|
{
|
|
name: 'disablePassStyles',
|
|
required: false,
|
|
type: 'boolean',
|
|
description: `Used to disable passing styles down to children.`,
|
|
},
|
|
]}
|
|
/>
|