-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
class name functions #257
class name functions #257
Conversation
Every component that accepts a className should be able to pass in a function. This function will retrieve the render prop arg for this component. The function should resolve to a string in the end. This makes the API a bit nicer if you just need to change the classNames based on some internal state. E.g.: ```js // Before <Menu.Button as={Fragment}> {({ open }) => ( <button className={open ? 'font-bold' : 'font-normal'}> Hello </button> )} </Menu.Button> // After <Menu.Button className={({ open }) => open ? 'font-bold' : 'font-normal'}> Hello </Menu.Button> ```
This pull request is being automatically deployed with Vercel (learn more). headlessui-react – ./packages/@headlessui-react🔍 Inspect: https://vercel.com/tailwindlabs/headlessui-react/9smLTh7YjjqvAFzT31Kdfw1UAx4j headlessui-vue – ./packages/@headlessui-vue🔍 Inspect: https://vercel.com/tailwindlabs/headlessui-vue/5yEun6TrZFB9uE8oRZZf1mtNnZtB |
d2ed69b
to
5ae539d
Compare
* allow className to be a function Every component that accepts a className should be able to pass in a function. This function will retrieve the render prop arg for this component. The function should resolve to a string in the end. This makes the API a bit nicer if you just need to change the classNames based on some internal state. E.g.: ```js // Before <Menu.Button as={Fragment}> {({ open }) => ( <button className={open ? 'font-bold' : 'font-normal'}> Hello </button> )} </Menu.Button> // After <Menu.Button className={({ open }) => open ? 'font-bold' : 'font-normal'}> Hello </Menu.Button> ``` * cleanup types * merge React imports * update changelog
* allow className to be a function Every component that accepts a className should be able to pass in a function. This function will retrieve the render prop arg for this component. The function should resolve to a string in the end. This makes the API a bit nicer if you just need to change the classNames based on some internal state. E.g.: ```js // Before <Menu.Button as={Fragment}> {({ open }) => ( <button className={open ? 'font-bold' : 'font-normal'}> Hello </button> )} </Menu.Button> // After <Menu.Button className={({ open }) => open ? 'font-bold' : 'font-normal'}> Hello </Menu.Button> ``` * cleanup types * merge React imports * update changelog
* allow className to be a function Every component that accepts a className should be able to pass in a function. This function will retrieve the render prop arg for this component. The function should resolve to a string in the end. This makes the API a bit nicer if you just need to change the classNames based on some internal state. E.g.: ```js // Before <Menu.Button as={Fragment}> {({ open }) => ( <button className={open ? 'font-bold' : 'font-normal'}> Hello </button> )} </Menu.Button> // After <Menu.Button className={({ open }) => open ? 'font-bold' : 'font-normal'}> Hello </Menu.Button> ``` * cleanup types * merge React imports * update changelog
* allow className to be a function Every component that accepts a className should be able to pass in a function. This function will retrieve the render prop arg for this component. The function should resolve to a string in the end. This makes the API a bit nicer if you just need to change the classNames based on some internal state. E.g.: ```js // Before <Menu.Button as={Fragment}> {({ open }) => ( <button className={open ? 'font-bold' : 'font-normal'}> Hello </button> )} </Menu.Button> // After <Menu.Button className={({ open }) => open ? 'font-bold' : 'font-normal'}> Hello </Menu.Button> ``` * cleanup types * merge React imports * update changelog
Every component that accepts a className should be able to pass in a
function. This function will retrieve the render prop arg for this
component. The function should resolve to a string in the end.
This makes the API a bit nicer if you just need to change the classNames
based on some internal state.
E.g.: