--- title: UI components | Stainless description: Learn how to use UI components from Stainless and third-parties in your docs. --- ## Stainless components We provide the following components in the Stainless Docs Platform: - [Accordion](#accordion) - [Badge](#badge) - [Button](#button) - [Callout](#callout) - [Steps](#steps) ### Accordion The `` component is an enhanced version of the HTML `
` element: This is an example `` component Additional details, visible when the `` is open. Example code ``` import { Accordion } from '@stainless-api/docs/components'; This is an example `` component Additional details, visible when the `` is open. ``` Any valid [`
` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/details#attributes) can be used with an `` component. #### Open by default To make an `` open by default, add an `open` prop: This ``’s details are visible by default You can see this immediately! Example code ``` import { Accordion } from '@stainless-api/docs/components'; This ``'s details are visible by default You can see this immediately! ``` #### Group `` components Group `` components by nesting them inside an ``: Item one Further information about item one. Item two Further information about item two. Item three Further information about item three. Example code ``` import { Accordion } from '@stainless-api/docs/components'; Item one Further information about item one. Item two Further information about item two. Item three Further information about item three. ``` ### Badge The `` component is useful whenever you want to add a badge or indicator: Beta Example of a badge that indicates a beta feature. Example code ``` import { Badge } from '@stainless-api/docs/components'; Beta Example of a beta badge. ``` #### Badge intents Set the `intent` prop on a `` to one of the values shown in the examples below to change its appearance. The `accent` variant uses the [accent color](/docs/docs-platform/customization/styles-and-fonts/#accent-color/index.md) you’ve configured on your site. These docs use a black accent color, so the examples below don’t appear appreciably different from the `default` and `muted` variants. none info success warning danger note tip accent Example code ``` import { Badge } from '@stainless-api/docs/components'; none info success warning danger note tip accent ``` #### Badge sizes Set the `size` prop on a `` to `sm`, `md`, or `lg` to adjust the size (the default is `md`): size=“sm” size=“md” size=“lg” Example code ``` import { Badge } from '@stainless-api/docs/components'; size="sm" size="md" size="lg" ``` #### Badge icons Use the `icon` prop via a [slot](https://docs.astro.build/en/guides/framework-components/#passing-children-to-framework-components) to add an icon to a ``: Ghosts! Example code ``` import { Badge } from '@stainless-api/docs/components'; import { Ghost } from 'lucide-react'; Ghosts! ``` #### Make a badge solid Set the `solid` prop to `true` to make a badge solid: Solid! Regular Example code ``` import { Badge } from '@stainless-api/docs/components'; Solid! Regular ``` #### HTTP method badges We provide an HTTP method badge variant, ``, that matches the badges in the API reference we generate for you. Set the `method` prop to the HTTP method of your choice to use this variant: GET POST PUT PATCH DELETE Example code ``` import { Badge } from '@stainless-api/docs/components'; \ ``` If you only want the HTTP method icon, add `iconOnly`: Example code ``` import { Badge } from '@stainless-api/docs/components'; ``` ### Button Our ` ``` #### Button variants Set the `variant` prop on a ` ``` #### Button size Set the `size` prop to `sm` or `lg` to decrease or increase the size of a ` ``` ### Callout Use a `` to emphasize important information, like warnings or noteworthy details. Some important information. Example code ``` import { Callout } from '@stainless-api/docs/components'; Some important information. ``` #### Callout variants Set the `variant` prop to one of the values in the examples below for different `` use cases: info note tip success warning danger Example code ``` import { } from '@stainless-api/docs/components'; info note tip success warning danger ``` ### Steps Use our `` and `` components for step-by-step instructions: 1. Read these docs 2. Allow your brain to process the information 3. You now know how to use our UI components! Example code ``` import { Steps, Step } from '@stainless-api/docs/components'; Read these docs Allow your brain to process the information You now know how to use our UI components! ``` ## Other UI components The Stainless Docs Platform is built on Astro, which means you’re free to use any basically any UI components you wish. We provide [built-in support for React components](#add-a-react-component), but Astro supports many other frontend frameworks. Have a look at [Astro’s component documentation](https://docs.astro.build/en/basics/astro-components/) and [Astro’s guide to using framework components](https://docs.astro.build/en/guides/framework-components/#using-framework-components) for more details. Currently, the Stainless Docs platform also supports [Starlight components](https://starlight.astro.build/components/using-components/), but the use of Starlight is considered an implementation detail that is subject to change. To maintain compatibility with future versions of the Stainless Docs Platform, we recommend using Stainless UI components instead of Starlight components whenever possible. ### Add a React component To add a React component to your site, we recommend you put the component’s code in a file in `src/components`: src/components/Counter.tsx ``` import { useState } from "react"; export default function Counter() { const [count, setCount] = useState(0); return (
Counter: {count}
); } ``` Next, import the component on any page of your site: src/content/docs/example-page.mdx ``` --- title: Example page --- import Counter from "/src/components/Counter.tsx"; This is an example page with a counter: ``` Only add `client:load` when your component requires client-side interactivity, or when your component must be rendered client-side to function properly. Components without `client:load` will be rendered server-side at build time to decrease bundle sizes and increase client-side performance, but they will not be interactive. See the [Astro client-directives documentation](https://docs.astro.build/en/reference/directives-reference/#client-directives) for more information.