Skip to content

Commit

Permalink
docs: add ToggleButton documentation (#4510)
Browse files Browse the repository at this point in the history
  • Loading branch information
plagoa authored Jan 15, 2025
1 parent 4c17075 commit 920a37d
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions apps/docs/src/pages/components/toggle-button.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { HvToggleButton } from "@hitachivantara/uikit-react-core";
import { Favorite, FavoriteSelected } from "@hitachivantara/uikit-react-icons";

import Playground from "@docs/components/code/Playground";
import { Description } from "@docs/components/page/Description";
import { Page } from "@docs/components/page/Page";
import { getComponentData } from "@docs/utils/component";

export const getStaticProps = async ({ params }) => {
const meta = await getComponentData("ToggleButton", "core", []);
return { props: { ssg: { meta } } };
};

<Description />

<Page>

<Playground
Component={HvToggleButton}
componentName="HvToggleButton"
controls={{
selected: {
defaultValue: false,
},
disabled: {
defaultValue: false,
},
}}
componentProps={{
notSelectedIcon: <Favorite />,
selectedIcon: <FavoriteSelected />,
}}
/>

### With tooltip

You can wrap the toggle button with a tooltip to provide additional information.

```tsx live
import { useState } from "react";

export default function Demo() {
const [selected, setSelected] = useState(false);

return (
<HvTooltip title={selected ? "Turn off" : "Turn on"}>
<HvToggleButton onClick={() => setSelected(!selected)}>
{selected ? <LightOn /> : <LightOff />}
</HvToggleButton>
</HvTooltip>
);
}
```

</Page>

0 comments on commit 920a37d

Please sign in to comment.