Skip to content

Commit

Permalink
Merge pull request #2417 from WTTJ/fix-toggle-label-alignment
Browse files Browse the repository at this point in the history
fix: toggle label alignment and toggle zIndex
  • Loading branch information
mleralec authored Mar 12, 2024
2 parents 7eb3759 + 578709c commit 5b82199
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
17 changes: 17 additions & 0 deletions docs/pages/components/toggle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,23 @@ function() {
}
```

Or use the `Label` component

```jsx
function() {
const [toggle, setToggle] = React.useState(false)

return (
<Stack>
<Label>
<Toggle size="sm" checked={toggle} onClick={() => setToggle(!toggle)} />
<span>Toggle</span>
</Label>
</Stack>
)
}
```

## Hint

Use Field component to add a `hint`
Expand Down
4 changes: 2 additions & 2 deletions packages/Core/src/theme/toggles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { CSSObject } from '@xstyled/styled-components'
import { WuiTheme } from './types'

// To allow for line-height of text in label
const XS_LINE_HEIGHT_ADJUSTMENTS = '0.40rem'
const SM_LINE_HEIGHT_ADJUSTMENTS = '0.10rem'
const XS_LINE_HEIGHT_ADJUSTMENTS = '0.32rem !important'
const SM_LINE_HEIGHT_ADJUSTMENTS = '0.12rem ! important'

type State = 'default' | 'checked' | 'disabled' | 'sizes'

Expand Down
2 changes: 1 addition & 1 deletion packages/Toggle/src/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const Toggle = styled(Ariakit.Checkbox).withConfig({ shouldForwardProp })
position: absolute;
margin: auto;
transition: medium;
z-index: 2;
z-index: 1;
}
&:disabled {
Expand Down

0 comments on commit 5b82199

Please sign in to comment.