Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): Add component and slotProps properties to the button and the icon button #22

Merged
merged 8 commits into from
Oct 6, 2024
42 changes: 39 additions & 3 deletions apps/website/docs/apis/15-button.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ For examples and details on the usage of this React component, visit the compone

## Import

```jsx
```tsx
import { Button } from 'tailwind-joy/components';
```

Expand All @@ -32,8 +32,11 @@ The `ref` is forwarded to the root element.

:::

By default, props available for HTML `<button>` are also available for Button component.
Other props are as follows:
### `className`

Class name applied to the root element.

- Type: `string`

### `color`

Expand All @@ -42,6 +45,22 @@ The color of the component.
- Type: `'primary' | 'neutral' | 'danger' | 'success' | 'warning'`
- Default: `'primary'`

### `component`

<AvailableFrom version="0.4.0" />

The component used for the root node.

- Type: `keyof JSX.IntrinsicElements`
- Default: `'button'`

### `disabled`

If `true`, the component is disabled.

- Type: `boolean`
- Default: `false`

### `endDecorator`

Element placed after the children.
Expand Down Expand Up @@ -83,6 +102,23 @@ The size of the component.
- Type: `'sm' | 'md' | 'lg'`
- Default: `'md'`

### `slotProps`

<AvailableFrom version="0.4.0" />

The props used for each slot inside.

- Type:
```tsx
{
root?: ComponentProps<'button'>;
startDecorator?: ComponentProps<'span'>;
endDecorator?: ComponentProps<'span'>;
loadingIndicatorCenter?: ComponentProps<'span'>;
}
```
- Default: `{}`

### `startDecorator`

Element placed before the children.
Expand Down
40 changes: 37 additions & 3 deletions apps/website/docs/apis/36-icon-button.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ For examples and details on the usage of this React component, visit the compone

## Import

```jsx
```tsx
import { IconButton } from 'tailwind-joy/components';
```

Expand All @@ -32,8 +32,11 @@ The `ref` is forwarded to the root element.

:::

By default, props available for HTML `<button>` are also available for IconButton component.
Other props are as follows:
### `className`

Class name applied to the root element.

- Type: `string`

### `color`

Expand All @@ -42,6 +45,22 @@ The color of the component.
- Type: `'primary' | 'neutral' | 'danger' | 'success' | 'warning'`
- Default: `'neutral'`

### `component`

<AvailableFrom version="0.4.0" />

The component used for the root node.

- Type: `keyof JSX.IntrinsicElements`
- Default: `'button'`

### `disabled`

If `true`, the component is disabled.

- Type: `boolean`
- Default: `false`

### `loading`

If `true`, the loading indicator is shown and the button becomes disabled.
Expand All @@ -63,6 +82,21 @@ The size of the component.
- Type: `'sm' | 'md' | 'lg'`
- Default: `'md'`

### `slotProps`

<AvailableFrom version="0.4.0" />

The props used for each slot inside.

- Type:
```tsx
{
root?: ComponentProps<'button'>;
loadingIndicator?: ComponentProps<'span'>;
}
```
- Default: `{}`

### `variant`

The variant of the component.
Expand Down
Loading