@material-tailwind
Material Tailwind
@material-tailwind is an easy to use components library for Tailwind CSS and Material Design. It features multiple React components, all written with Tailwind CSS classes and Material Design guidelines. Coming soon components for VueJS, Angular and many more. Add this repository to your watch list to get the latest news, or join our newsletter community: https://material-tailwind.com/.
Table of Contents
Components
- Alerts
- Buttons
- Cards
- Checkbox
- Dropdowns
- Dropups
- Images
- Inputs
- Labels
- Menus
- Modals
- Navbars
- Paginations
- Popovers
- Progressbars
- Radio Button
- Tabs
- Textarea
- Tooltips
- Typography
Quick start
React
Using NPM
npm i -E @material-tailwind/react
Using Yarn
yarn add @material-tailwind/react -E
Import Material Tailwind Style Sheet
Import the tailwind.css
into your app.js
file. Make sure to import the tailwind.css
style sheet after all other style sheets.
import "@material-tailwind/react/tailwind.css";
Link Material Icons Fonts to your project
Add a link for the material icons fonts inside the head of your project, so to use the material icons with material tailwind components. You can also use font awesome font family for the project just add a link for it inside the head of your project.
// Font Awesome Link ">// Material Icons Link
// Font Awesome Link
Documentation - React
After you have installed @material-tailwind
into your project, you can import and use our components like so:
Usage
import React from "react";
import Button from "@material-tailwind/react/Button";
export default function Example() {
return (
)
}
Browser Support
At present, we officially aim to support the last two versions of the following browsers:
Chrome | Firefox | Edge | Safari | Opera |
---|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
Reporting Issues
We use GitHub Issues as the official bug tracker for the @material-tailwind. Here are some advices for our users that want to report an issue:
- Make sure that you are using the latest version of the @material-tailwind.
- Providing us reproducible steps for the issue will shorten the time it takes for it to be fixed.
- Some issues may be browser specific, so specifying in what browser you encountered the issue might help.
Licensing
-
Copyright 2021 Creative Tim
-
Licensed under MIT
Useful Links
- Tutorials
- Affiliate Program (earn money)
- Blog Creative Tim
- Free Products from Creative Tim
- Premium Products from Creative Tim
- React Products from Creative Tim
- Angular Products from Creative Tim
- VueJS Products from Creative Tim
- More products from Creative Tim
- Check our Bundles here
- Check our awesome builder here
Social Media
Twitter: https://twitter.com/CreativeTim
Facebook: https://www.facebook.com/CreativeTim
Dribbble: https://dribbble.com/creativetim
Instagram: https://www.instagram.com/creativetimofficial/
SyntaxError: Unexpected token 'export'
Hello, I have used old version and it run well until new version come out. I follow instruction to install new version, however I get error:
Here is my _app.js code:
this is tailwind.config.js
Typescript support
Expected Behavior
Should be able to use in TS project without any errors saying it
Could not find a declaration file for module
@material-tailwind/react/*`.Current Behavior
I cannot use it in TS project as seen here:
Possible Solution
Add native TS support or create typings.
Steps to Reproduce (for bugs)
Your Environment
Current version of material-tailwind. NextJS TS project.
Customize Button component to add a color
Hello,
I'm sorry but I don't really understand how can I add a color to the button's list color
type color = | "blue-gray" | "gray" | "brown" | "deep-orange" | "orange" | "amber" | "yellow" | "lime" | "light-green" | "green" | "teal" | "cyan" | "light-blue" | "blue" | "indigo" | "deep-purple" | "purple" | "pink" | "red";
I've created a "primary color" in my tailwind.config.js file ( primary: '#369BB0',)
I now 'd like to add this color to the list of color of button component but don't know how.
Thank you !
Icon button is not able to get the Icons
I am working on Next JS and trying to add an Icon to my page. I started with an example given on the page
Do I need to add any dependencies or Am I missing any obvious reference? I added font awesome but it did not help.
FIX: Props interface was created but never used
In that file props interface was created but was never used to type define the component props.
My first pull request....still learning hope the thing i did was correct
Customization of Chip coponent
Hello,
I id like to customize the Chip component in order to use my own colors, etc. I use react and typescript. I receive an error due to my customization "TypeError: Cannot convert undefined or null to object"
I, firstly, created a customChip component based on Chip component from Material-tailwind :
interface CustomChipProps extends Omit<ChipProps, "color"> { variant?: "filled" | "gradient"; className?: string; value: string; color?: | "primary" | "secondary" | "warning" }
export default function CustomChip(props: CustomChipProps) { return <Chip {...(props as any)} />; }
then I create a baseChip component based on my CustomChip component :
export const BaseChip: React.FC<React.PropsWithChildren<CustomChipProps>> = ( props: React.PropsWithChildren<CustomChipProps> ): JSX.Element => ( <CustomChip variant={props.variant} color={props.color} value={props.value} /> );
on my theme file, i added the chip component, I think the problem is here, my I did an error but i don't know how to custom each part :
chip: { defaultProps: { variant: 'filled', color: 'primary', show: true, size: 'sm', }, valid: { variants: ['filled'], colors: ['primary', 'secondary', 'warning', 'dark'], }, styles: { base: { position: "relative", }, variants: { filled: { primary: { background: 'bg-primary', color: 'text-white', }, secondary: { background: 'bg-secondary', color: 'text-dark', }, }, }, closeButtonColor: { filled: { primary: { color: 'text-white', }, secondary: { color: 'text-dark', }, warning: { color: 'text-white', }, }, }, },
Thank you Kilian`
Checkbox and Inputs cannot be controlled
I appologize in advance if I don't understand exactly how is supposed to be done or couldn't find the proper solution in the docs, feel free to close issue with an answer or a link, but I don't think the input and checkbox components have props to be controlled, the input doesnt have a
value
prop nor the checkbox has achecked
prop.Any ways to control them? There is neither a prop to pass
{ ...props }
to the inside component as they often are wrapped in a div or a label inside a div, how would we go about this?Global CSS cannot be imported from within node_modules
In trying to use the
Popover
component in a Nextjs codebase,I get the following error in Nextjs:
Nextjs doesn't like it when a package is importing a CSS file from another module. See: https://nextjs.org/docs/messages/css-npm
NextJS build fails because of react-merge-refs
I don't even use Dialog component.
Node version: 16.14.2
package.json
Required attr. support for inputs
Hi,
One of the thing I always need is the required attribute for fields. In MUI, addind a "required" prop also appends an asterisk after the label.
I struggled a bit to be able to append it myself as "required" is not a prop here and I couldn't pass element for the label. The "after" pseudo element is already taken for the focus animation, so the only workaround I found was to use the before element and play with TW classes such as :
As you can see, it's pretty ugly because the TW JIT dynamic values only match with the current label length. I think it would be nice to be able to either pass a custom element as label or to support the required attr. and auto add the usual asterisk element. Or just tell me if you have already figured out a way to solve this problem..
Otherwise, happy to get rid of the original cumbersome MUI lib 👍
Breakpoints not working with Material Tailwind & Next.js
Expected Behavior
After starting a fresh project with the next.js tailwindCSS starter template and installing the material-tailwind package as per the docs, I created a heading which I expect to be aligned to the left from medium screens and up.
The code used is as follows:
Current Behavior
Instead I get the text centered at all screen sizes (breakpoints). This happens with multiple components within my fresh application.
Possible Solution
The only way I can get the application to work as intended is to remove the line importing the material tailwind CSS in the
_app.js
file and keep thetailwindcss/tailwind.css
style import.My
_app.js
file is as follows:Steps to Reproduce (for bugs)
npx create-next-app -e with-tailwindcss my-project
npm install -D [email protected] [email protected] [email protected]
npx tailwindcss init -p
npm i -E @material-tailwind/react
_app.js
looks like so:index.js
create a component as follows:Context
I was watching a live coding session on YT and I saw the programmer run into this problem and not resolve it so I just had a quick look.
Your Environment
How to use theming ficture to properly create a dark/light theme switcher
Hello, currently the documentation is a bit too confusing(kinda empty) about how to use the theming ficture of the librarie, can someone explain what are the propertys i need to pass on the theme vaue object? thx.
Support for NextJS 13 and server components
Will Material Tailwind get full support for nextJS 13 and Reacts server components? To utilise server components and MTW we would need to make every component as a client component.
idea: add section about testing with jest
since material-tailwind components make use of the web animations API (which seems to be unsupported by jsdom) I think quite a few users might run into issues when testing interactions with components that use this component library.
Maybe it would make sense to include a little section about how to set up get jest working with material-tailwind?
E.g. by hinting to https://www.npmjs.com/package/jsdom-testing-mocks#mock-web-animations-api (no affiliation, but seems to work for me)
Feature Request: Date and Time pickers
I like the ease of using this with Remix. So far, so good.
Would like to request: DateField, TimeField (and combo of those). Also would love to see Calendar Picker (bonus: with Date Range)