Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
hbjORbj committed Apr 26, 2023
1 parent 3a29767 commit d7defa8
Show file tree
Hide file tree
Showing 83 changed files with 725 additions and 384 deletions.
17 changes: 4 additions & 13 deletions docs/data/base/components/input/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,20 @@ The Input component is composed of a root `<div>` slot that houses one interior
</div>
```

### Slot props
### Custom structure

:::info
The following props are available on all non-utility Base components.
See [Usage](/base/getting-started/usage/) for full details.
:::

Use the `component` prop to override the root slot with a custom element:
Use the `slots.root` prop to override the root slot with a custom element:

```jsx
<Input component="aside" />
<Input slots={{ root: 'aside' }} />
```

Use the `slots` prop to override any interior slots in addition to the root:

```jsx
<Input slots={{ root: 'aside' }} />
<Input slots={{ root: 'aside', input: 'button' }} />
```

:::warning
If the root element is customized with both the `component` and `slots` props, then `component` will take precedence.
:::

Use the `slotProps` prop to pass custom props to internal slots.
The following code snippet applies a CSS class called `my-input` to the input slot:

Expand Down
13 changes: 2 additions & 11 deletions docs/data/base/components/select/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,9 @@ Option renders as an `<li>`:
</div>
```

### Slot props
### Custom structure

:::info
The following props are available on all non-utility Base components.
See [Usage](/base/getting-started/usage/) for full details.
:::

Use the `component` prop to override the root slot with a custom element:
Use the `slots.root` prop to override the root slot with a custom element:

```jsx
<Select component="div" />
Expand All @@ -131,10 +126,6 @@ Use the `slots` prop to override any interior slots in addition to the root:
<Select slots={{ root: 'div', listbox: 'ol' }} />
```

:::warning
If the root element is customized with both the `component` and `slots` props, then `component` will take precedence.
:::

Use the `slotProps` prop to pass custom props to internal slots.
The following code snippet applies a CSS class called `my-listbox` to the listbox slot:

Expand Down
27 changes: 16 additions & 11 deletions docs/data/base/components/slider/slider.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,9 @@ The Slider component is composed of a root `<span>` that houses several interior
Both the `mark` and `markLabel` slots have corresponding `*Active` classes that are applied conditionally.
:::

### Slot props
### Custom structure

:::info
The following props are available on all non-utility Base components.
See [Usage](/base/getting-started/usage/) for full details.
:::

Use the `component` prop to override the root slot with a custom element:
Use the `slots.root` prop to override the root slot with a custom element:

```jsx
<Slider component="div" />
Expand All @@ -117,17 +112,27 @@ Use the `slots` prop to override any interior slots in addition to the root:
<Slider slots={{ root: 'div', thumb: 'div' }} />
```

:::warning
If the root element is customized with both the `component` and `slots` props, then `component` will take precedence.
:::

Use the `slotProps` prop to pass custom props to internal slots.
The following code snippet applies a CSS class called `my-rail` to the rail slot:

```jsx
<Slider slotProps={{ rail: { className: 'my-rail' } }} />
```

#### Usage with TypeScript

In TypeScript, you can specify the custom component type used in the `slots.root` as a generic to the unstyled component. This way, you can safely provide the custom compoenent's props directly on the compnent:

```tsx
<Button<typeof CustomComponent> slots={{ root: CustomComponent }} customProp />
```

The same applies for props specific to custom primitive elements:

```tsx
<Button<'img'> slots={{ root: 'img' }} src="button.png" />
```

## Hook

```js
Expand Down
23 changes: 16 additions & 7 deletions docs/data/base/components/snackbar/snackbar.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,28 @@ The Snackbar component is composed of a single root `<div>` slot with no interio
<div role="presentation" className="BaseSnackbar-root">snackbar content</div>
```

### Slot props
### Custom structure

:::info
The following props are available on all non-utility Base components.
See [Usage](/base/getting-started/usage/) for full details.
:::

Use the `component` prop to override the root slot with a custom element:
Use the `slots.root` prop to override the root slot with a custom element:

```jsx
<Snackbar component="span" />
```

#### Usage with TypeScript

In TypeScript, you can specify the custom component type used in the `slots.root` as a generic to the unstyled component. This way, you can safely provide the custom compoenent's props directly on the compnent:

```tsx
<Button<typeof CustomComponent> slots={{ root: CustomComponent }} customProp />
```

The same applies for props specific to custom primitive elements:

```tsx
<Button<'img'> slots={{ root: 'img' }} src="button.png" />
```

## Hook

```js
Expand Down
32 changes: 28 additions & 4 deletions docs/data/base/components/switch/UnstyledSwitchIntroduction.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,34 @@ export default function UnstyledSwitches() {

return (
<div>
<Switch component={Root} {...label} defaultChecked />
<Switch component={Root} {...label} />
<Switch component={Root} {...label} defaultChecked disabled />
<Switch component={Root} {...label} disabled />
<Switch
slots={{
root: Root,
}}
{...label}
defaultChecked
/>
<Switch
slots={{
root: Root,
}}
{...label}
/>
<Switch
slots={{
root: Root,
}}
{...label}
defaultChecked
disabled
/>
<Switch
slots={{
root: Root,
}}
{...label}
disabled
/>
</div>
);
}
32 changes: 28 additions & 4 deletions docs/data/base/components/switch/UnstyledSwitchIntroduction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,34 @@ export default function UnstyledSwitches() {

return (
<div>
<Switch component={Root} {...label} defaultChecked />
<Switch component={Root} {...label} />
<Switch component={Root} {...label} defaultChecked disabled />
<Switch component={Root} {...label} disabled />
<Switch<typeof Root>
slots={{
root: Root,
}}
{...label}
defaultChecked
/>
<Switch<typeof Root>
slots={{
root: Root,
}}
{...label}
/>
<Switch<typeof Root>
slots={{
root: Root,
}}
{...label}
defaultChecked
disabled
/>
<Switch<typeof Root>
slots={{
root: Root,
}}
{...label}
disabled
/>
</div>
);
}
32 changes: 28 additions & 4 deletions docs/data/base/components/switch/UnstyledSwitches.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,34 @@ export default function UnstyledSwitches() {

return (
<div>
<Switch component={Root} {...label} defaultChecked />
<Switch component={Root} {...label} />
<Switch component={Root} {...label} defaultChecked disabled />
<Switch component={Root} {...label} disabled />
<Switch
slots={{
root: Root,
}}
{...label}
defaultChecked
/>
<Switch
slots={{
root: Root,
}}
{...label}
/>
<Switch
slots={{
root: Root,
}}
{...label}
defaultChecked
disabled
/>
<Switch
slots={{
root: Root,
}}
{...label}
disabled
/>
</div>
);
}
32 changes: 28 additions & 4 deletions docs/data/base/components/switch/UnstyledSwitches.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,34 @@ export default function UnstyledSwitches() {

return (
<div>
<Switch component={Root} {...label} defaultChecked />
<Switch component={Root} {...label} />
<Switch component={Root} {...label} defaultChecked disabled />
<Switch component={Root} {...label} disabled />
<Switch<typeof Root>
slots={{
root: Root,
}}
{...label}
defaultChecked
/>
<Switch<typeof Root>
slots={{
root: Root,
}}
{...label}
/>
<Switch<typeof Root>
slots={{
root: Root,
}}
{...label}
defaultChecked
disabled
/>
<Switch<typeof Root>
slots={{
root: Root,
}}
{...label}
disabled
/>
</div>
);
}
27 changes: 16 additions & 11 deletions docs/data/base/components/switch/switch.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,9 @@ The Switch component is composed of a root `<span>` that houses three interior s
</span>
```

### Slot props
### Custom structure

:::info
The following props are available on all non-utility Base components.
See [Usage](/base/getting-started/usage/) for full details.
:::

Use the `component` prop to override the root slot with a custom element:
Use the `slots.root` prop to override the root slot with a custom element:

```jsx
<Switch component="div" />
Expand All @@ -72,17 +67,27 @@ Use the `slots` prop to override any interior slots in addition to the root:
<Switch slots={{ root: 'div', track: 'div' }} />
```

:::warning
If the root element is customized with both the `component` and `slots` props, then `component` will take precedence.
:::

Use the `slotProps` prop to pass custom props to internal slots.
The following code snippet applies a CSS class called `my-thumb` to the thumb slot:

```jsx
<Switch slotProps={{ thumb: { className: 'my-thumb' } }} />
```

#### Usage with TypeScript

In TypeScript, you can specify the custom component type used in the `slots.root` as a generic to the unstyled component. This way, you can safely provide the custom compoenent's props directly on the compnent:

```tsx
<Button<typeof CustomComponent> slots={{ root: CustomComponent }} customProp />
```

The same applies for props specific to custom primitive elements:

```tsx
<Button<'img'> slots={{ root: 'img' }} src="button.png" />
```

## Hook

```js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ The `TablePaginationUnstyled` component is composed of a root `<td>` that houses
</td>
```

### Slot props
### Custom structure

:::info
The following props are available on all non-utility Base components. See [Usage](/base/getting-started/usage/) for full details.
:::

Use the `component` prop to override the root slot with a custom element:
Use the `slots.root` prop to override the root slot with a custom element:

```jsx
<TablePaginationUnstyled component="div" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ The `TablePaginationUnstyled` component is composed of a root `<td>` that houses
</td>
```

### Slot props
### Custom structure

:::info
The following props are available on all non-utility Base components. See [Usage](/base/getting-started/usage/) for full details.
:::

Use the `component` prop to override the root slot with a custom element:
Use the `slots.root` prop to override the root slot with a custom element:

```jsx
<TablePaginationUnstyled component="div" />
Expand Down
Loading

0 comments on commit d7defa8

Please sign in to comment.