# Slots API specification
## Slots definition
Fluent UI components are often composed internally with different subparts to help with layouts. These pre-defined layouts can be configured via the Slots API. Slots are named areas in a component that can receive props for styling and layout.
For example, `Button` component contains `content`, `loader` and `icon` slots in its layout:
```jsx
// β οΈ not a real JSX/DOM markup
```
Slots define the complex layouts required by many components according to accessibility and design requirements automatically. Slots can be configured through props, allowing the caller pass in a variety of inputs for a given slot.
## Slots components
Each slot is represented by a React component or a primitive, for example: `slots.loader` can be a `Loader` component and `slots.icon` can be a `span`:
```jsx
// β οΈ not a real JSX/DOM markup
<>
{/* renders a element */}
{/* renders a element */}
{/* renders a element */}
>
```
Slots are rendered as `div` elements by default. However, all rendering aspects of a slot can be manually configured and overridden.
## Slots usage
Slots can be configured with different types and shapes of values, but result should not change - slots will produce a correct layout inside a component.
### An object as a value
This behavior can be considered as declaring a JSX element with a javascript object. In an example below, props will be passed to an `icon` slot:
```jsx
, className: 'an-awesome-slot', id: '#button-icon' }} />
```
```html
```
Any props which are valid for a component can be passed to a slot, i.e. ARIA, `data-*` attributes and event handlers.
```jsx
,
// β ARIA attributes should be tweaked carefully, they are used there only for example
'aria-disabled': true,
'data-test-id': 'button-foo-icon',
onClick: () => {
console.log('A click on an icon slot!');
},
}}
/>
```
```html
```
Our components will prevent passing invalid props to DOM (check `getNativeElementProps()` for more details):
```jsx
```
```html
```
### Primitives as a value
We consider JSX elements as primitive values that will be passed to a meaningful prop, by default to `children` (but this can be configured in the component's implementation):
```jsx
<>
}} />
{/* π‘ will produce the same JSX/HTML markup, as will be expanded to { children: } */}
} />
>
```
Such usage of slots is called shorthands, similarly to [CSS shorthand properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Shorthand_properties). The same behavior is applicable strings and numbers:
```jsx
<>
{/* π‘ will produce the same JSX/HTML markup */}
>
```
To disable slot rendering you can use `null` as a value:
```jsx
// π‘ A loader slot will be hidden
```
### Renders props via `children` function
Slots can be deeply customized without ignoring the original content by using `children` as a function that behave similarly to [Render Props pattern](https://reactjs.org/docs/render-props.html) in React:
```jsx