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

[docs][base-ui]: Working With Tailwind Guide - revises example code to avoid import errors #38693

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,18 @@ Copy and paste the code below into the file:

```tsx
import * as React from 'react';
import { Slider, SliderThumbSlotProps, SliderProps } from '@mui/base/Slider';
import {
Slider as BaseSlider,
SliderThumbSlotProps,
SliderProps,
} from '@mui/base/Slider';

const Slider = React.forwardRef(function Slider(
props: SliderProps,
ref: React.ForwardedRef<HTMLSpanElement>,
) {
return (
<Slider
<BaseSlider
{...props}
ref={ref}
slotProps={{
Expand Down Expand Up @@ -334,7 +338,7 @@ To do this, it's not enough to just use classes for the thumb—we need also to
+++ b/src/Slider.tsx
@@ -1,6 +1,17 @@
import * as React from 'react';
import { Slider, SliderThumbSlotProps, SliderProps } from '@mui/base/Slider';
import { Slider as BaseSlider, SliderThumbSlotProps, SliderProps } from '@mui/base/Slider';

+const Thumb = React.forwardRef(function Thumb(
+ props: SliderThumbSlotProps,
Expand All @@ -351,11 +355,11 @@ To do this, it's not enough to just use classes for the thumb—we need also to
props: SliderProps,
ref: React.ForwardedRef<HTMLSpanElement>,
@@ -8,9 +19,11 @@ const Slider = React.forwardRef(function Slider(
return (<Slider
return (<BaseSlider
{...props}
ref={ref}
+ slots={{
+ thumb,
+ thumb: Thumb,
+ }}
slotProps={{
root: { className: 'w-full relative inline-block h-2 cursor-pointer' },
Expand Down Expand Up @@ -397,14 +401,18 @@ Create a `Button.tsx` file and copy the following code:

```tsx
import * as React from 'react';
import { Button, ButtonOwnerState, ButtonProps } from '@mui/base/Button';
import {
Button as BaseButton,
ButtonOwnerState,
ButtonProps,
} from '@mui/base/Button';

const Button = React.forwardRef(function Button(
props: ButtonProps,
ref: React.ForwardedRef<HTMLButtonElement>,
) {
return (
<Button
<BaseButton
{...props}
slotProps={{
root: (state: ButtonOwnerState) => ({
Expand Down