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]>
150 lines
3.2 KiB
Plaintext
150 lines
3.2 KiB
Plaintext
---
|
|
title: RadioGroup
|
|
description: Use in a form to allow selecting one option from multiple.
|
|
name: radio-group
|
|
component: RadioGroup
|
|
package: radio-group
|
|
demoName: RadioGroup
|
|
---
|
|
|
|
<HeroContainer>
|
|
<RadioGroupDemo />
|
|
</HeroContainer>
|
|
|
|
```tsx hero template=RadioGroup
|
|
|
|
```
|
|
|
|
<Highlights
|
|
features={[
|
|
`Accessible, easy to compose and customize.`,
|
|
`Sizable & works controlled or uncontrolled.`,
|
|
`Ability to opt-out to native radio button on web.`,
|
|
]}
|
|
/>
|
|
|
|
## Installation
|
|
|
|
RadioGroup is already installed in `hanzogui`, or you can install it independently:
|
|
|
|
```bash
|
|
npm install @hanzogui/radio-group
|
|
```
|
|
|
|
## Usage
|
|
|
|
```tsx
|
|
import { RadioGroup } from '@hanzo/gui'
|
|
|
|
export default () => (
|
|
<RadioGroup value="foo" gap="$2">
|
|
<RadioGroup.Item value="foo" id="foo-radio-item">
|
|
<RadioGroup.Indicator />
|
|
</RadioGroup.Item>
|
|
<RadioGroup.Item value="bar" id="bar-radio-item">
|
|
<RadioGroup.Indicator />
|
|
</RadioGroup.Item>
|
|
</RadioGroup>
|
|
)
|
|
```
|
|
|
|
## API Reference
|
|
|
|
### RadioGroup
|
|
|
|
RadioGroup extend Stack views inheriting all the [Gui standard props](/docs/intro/props), plus:
|
|
|
|
<PropsTable
|
|
data={[
|
|
{
|
|
name: 'name',
|
|
type: 'string',
|
|
description: `Equivalent to input name.`,
|
|
},
|
|
{
|
|
name: 'value',
|
|
type: 'string',
|
|
description: `Give it a value (for use in HTML forms).`,
|
|
},
|
|
{
|
|
name: 'required',
|
|
type: 'boolean',
|
|
description: `Sets aria-required.`,
|
|
},
|
|
{
|
|
name: 'disabled',
|
|
type: 'boolean',
|
|
description: `Set aria-disabled on web, and disable touch on native for all children items`,
|
|
},
|
|
{
|
|
name: 'native',
|
|
type: 'boolean',
|
|
description: `Renders native radio button on web.`,
|
|
default: false,
|
|
},
|
|
{
|
|
name: 'onValueChange',
|
|
type: '(value: string) => void',
|
|
},
|
|
{
|
|
name: 'accentColor',
|
|
type: 'string',
|
|
description: 'Sets `accent-color` style when `native` prop is enabled',
|
|
},
|
|
]}
|
|
/>
|
|
|
|
### RadioGroup.Item
|
|
|
|
<PropsTable
|
|
data={[
|
|
{
|
|
name: 'labeledBy',
|
|
type: 'string',
|
|
description: `Set aria-labeled-by on web`,
|
|
},
|
|
{
|
|
name: 'value',
|
|
type: 'string',
|
|
description: `Input value for the radio button.`,
|
|
},
|
|
{
|
|
name: 'disabled',
|
|
type: 'boolean',
|
|
description: `Set aria-disabled on web, and disable touch on native`,
|
|
},
|
|
{
|
|
name: 'id',
|
|
type: 'string',
|
|
description: `Id used on the web`,
|
|
},
|
|
{
|
|
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',
|
|
type: 'boolean',
|
|
default: 'false',
|
|
description: `When true, remove all default hanzogui styling.`,
|
|
},
|
|
]}
|
|
/>
|
|
|
|
### RadioGroup.Indicator
|
|
|
|
RadioGroup.Indicator appears only when the parent Item is checked. it extends [ThemeableStack](/docs/components/stacks#themeablestack), getting [Gui standard props](/docs/intro/props) adding:
|
|
|
|
<PropsTable
|
|
data={[
|
|
{
|
|
name: 'unstyled',
|
|
required: false,
|
|
type: `boolean`,
|
|
description: `Removes all default Gui styles.`,
|
|
},
|
|
]}
|
|
/>
|