Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: toggle label alignment and toggle zIndex #2417

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading