Tailwind svg fill not working. fill-current to set the fill color of an SVG...

Tailwind svg fill not working. fill-current to set the fill color of an SVG to the current text color. Utilities for controlling the background size of an element's background image. Dec 29, 2022 · I am using Tailwind with angular issue is I have svgs icon with my input and its not clickable I try to wrap with div or using cursor-pointer but nothing works. You can pass props such as width, height, fill, stroke, and any other attribute accepted by the native <svg> element. Dec 20, 2021 · Hi! For example, when using raw svg - you can add text-{current/color} class, but this class won't be applied if you have a fill option in there. I have a logo here in a component and I can't for the life of me get the className fill options to pass correctly. Utilities for styling the fill of SVG elements. Using utilities to style elements on hover, focus, and more. Might help to have the full svg/codepen Using and customizing the color palette in Tailwind CSS projects. In this post, we use Heroicons with both TailwindCSS and non-Tailwind classes. Basic usage Setting the fill color Use the fill-* utilities to change the fill color of an SVG. Learn fill, stroke, and advanced techniques for dynamic icons. configFile" setting in VS Code's settings. These icons come with a default height and width, just like the outline icons, and they also come with the fill attribute. Utilities for setting the width of an element. Jul 23, 2025 · Stroke Width of an SVG Element is a key property that defines the thickness of the outline for shapes like circles, rectangles, and paths. By the end of this article, you'll be able to get your Tailwind layouts working properly again. Enhance user experience with dynamic menu toggling. In Tailwind CSS, adjusting the stroke width is simple and can be done using utility classes. I did this before, I did this in some other places but, for some reason, it stopped working. Jan 5, 2022 · I'm running into the same issue It doesn't actually fill using the correct color. Feb 1, 2024 · 0 So I've been cracking at this and I can't seem to figure it out. Prefix an animation utility with a breakpoint A set of beautiful, customizable components that stay maintained and up to date. Jul 8, 2024 · 2 Answers Sorted by: if you use fill property, you should have parent element to be relative which you already set next. Approach: You can simply customize the class of SVG by adding text-colo r or background-color in icons, but in this process, you have to carefully use the utilities for styling the SVG like fill and stroke in Tailwind CSS. Dec 16, 2023 · Explore how to use SVGs, from the official Tailwind icons, Heroicons, and alternative options for incorporating icons into your design. May 2, 2012 · Furthermore, the second doesn't work because: bg-* arbitrary value class defaults to background-color if Tailwind can't determine the value type, as with CSS variables. Apr 18, 2024 · When working with SVG icons, colors are typically managed through two inline attributes: fill and stroke. I want to make the star itself completely yellow from the inside. Dec 1, 2020 · Learn how to change SVG color fill on hover using Tailwind CSS with practical examples and expert advice from the Stack Overflow community. Tailwind CSS Fill The fill property in CSS is used to set the color of SVG shapes, such as paths, circles, rectangles, etc. Utilities for styling the fill of SVG elements. Global Styling Adjusting icons can be done by color, size and stroke width. Beautiful hand-crafted SVG icons, by the makers of Tailwind CSS. svg path { f Aug 19, 2024 · Besides, we can also pass regular properties such as stroke, fill, width and height of the <svg> to the Heroicon, which is assigned to the <svg> element. For shapes and text it's a presentation attribute that defines the color (or any SVG paint servers like gradients or patterns) used to paint the element; for animation it defines the final state of the animation. Importing as a React Component: In this approach, you can import SVG files directly as React components. bg-green-100 aside. Backgrounds background-image Utilities for controlling an element's background image. If op classes the svg and not the parent div the path should inherit the full (depending on reset and the rest of the svg content) I’ve changed fills on super basic svgs by targeting the svg itself. Learn how to change the color of an SVG element using CSS techniques and properties. Style by using CSS Styling icons is easy to accomplish using CSS. While these docs use react-native-svg, the concept applies to all libraries. By default, the SVG's fill property doesn't magically inherit this color value. You need to use the <svg> tag to manipulate it with the utilities, as suggested by @talkenson. Sep 6, 2021 · Besides this behaviour and params like min-w-[300px] everything works well when I use things from tailwind. 2- Use the svg directly as inline element in your html and then you can change the fill using css fill:"#color" Feb 4, 2019 · Maybe this is obvious, but when I did this using svgs I made in inkscape, there was also a style tag at the bottom of the svg with fill=#000000 that was overriding my color preferences. h-full. Tailwind's text-red-500 sets the CSS color property. Learn about browser support and compatibility with other tooling. Dec 21, 2021 · Hi @ArgekarStudios, if I'm not mistaken, this is not possible in HTML/CSS in general, so not even in Tailwind. The built-in Tailwind utility fill-current is your best friend here! Jul 6, 2023 · Master SVG color manipulation with Tailwind CSS. Use utilities like fill-indigo-500 and fill-lime-600 to change the fill color of an SVG: This can be useful for styling icon sets like Heroicons. This makes it easy to set an element's fill color by combining this class with an existing text color utility. Jul 19, 2020 · We can adjust three other aspects of the SVG with Tailwind utilities: fill color, stroke color, and stroke width. If your SVG is in your code base, it is much better to set fill="currentColor", and then set the CSS color property. Anyone know how? To change any SVG with CSS, you need to target the fill property of the SVG itself. Your HTML: Resizing with Tailwind h-* and w-* utilities can be used to adjust the size of the icon. Jun 5, 2024 · With invert(1) you change it from black to white even in light mode (try commenting out inverting part). The fill attribute can be used with the following SVG elements: <circle>, <ellipse>, <path>, <polygon>, <polyline>, <rect>, <text>, <textPath>, <tref> and <tspan>. my take: div. Utilities for controlling how a replaced element's content should be resized. Nov 9, 2017 · You can't change fill color using style if the svg is applied to img tag You have 2 solutions: 1- Change it inside the svg file itself, this will work if it will always have a single color. flex-col. In such cases, the stroke-{color} class should be used. Jul 9, 2021 · tailwind css svg icon text center is not working Asked 4 years, 8 months ago Modified 4 years, 8 months ago Viewed 4k times Flexbox & Grid flex-basis Utilities for controlling the initial size of flex items. that my_flex Nov 28, 2022 · All classes was applied, but there is a once that doesnt work, Its SVG element`s fill key. May 14, 2016 · I'm trying to fill a twitter icon SVG with it's color through CSS. If you have a specific section you want to adjust within the viewport, you can further customize it using the h-[calc(100vh_-_150px)] class, adjusting the height accordingly. Also see this thread if you're using older Chrome: CSS prefers-color-scheme works on Firefox but not on Chrome issue Dec 10, 2021 · The current part in fill-current is coming from your colors in the tailwind. 2- Use the svg directly as inline element in your html and then you can change the fill using css fill:"#color" Style SVGs effortlessly with Tailwind CSS utilities for fill, stroke, and stroke-width, ensuring flexible, accessible, and theme-consistent designs across projects. SVG files have a . Aug 5, 2025 · The fill attribute has two different meanings. polygon. However, even when the SVG is properly formatted to use fill: currentColor, the fill does not match the currentColor (the text color) of the parent element (an img tag). Apr 16, 2022 · Please create a new issue that includes a reproduction showing it not working so we can clone it down and troubleshoot it in the fastest possible way. Aug 5, 2023 · Hence one of the common problems. Jan 7, 2025 · Here are a few common methods. If you're doing this method and it still isn't updating or only the stroke is updating, then that might be worth considering. Here's the CSS code: . Jul 8, 2021 · 2 You need to remove fill="#7400B8" attributes from each path element. I am using tailwind and trying to fill in the color of this star icon. Fill on a div is an invalid property (I believe) Edit wait no that’s not right either. bg-blue-100#left-pane div. Responsive design Prefix a rotate utility with a breakpoint variant like md: to only apply the utility at medium screen sizes and above: Feb 20, 2026 · React Native does not have SVG components but universal SVG support can be achieved with 3rd party libraries such as react-native-svg. Feb 8, 2026 · Set SVG fill colors in Tailwind CSS with fill-{color} utilities. that makes me think that those classes Copy Utilities for styling the fill of SVG elements. Tailwind CSS Autofill and Scrollbar Styling with ShadCN and Dark/Light Mode If you're using ShadCN and implementing dark and light modes in your project, you might have encountered issues with the background color of autofilled input fields. Oct 9, 2020 · The classes specified in the svg file don't register so I applied them to the helper. Might help to have the full svg/codepen SVG fill Attribute The fill attribute defines the color of the inside of an element. Utilities for rotating elements. Jan 17, 2023 · The tailwind play platform with a Heroicon styled svg house icon. We'll cover the common causes of the problem and provide solutions for each one. Fill color Use . I tried a lot ways to do it, but there is no result. This makes it easy to set an element’s fill color by combining this class with an existing text color utility. I deleted that line and it worked. Mar 17, 2018 · So you are setting it to text-grey-darker no matter what. Remove text-grey-darker from your SVG and everything will work as expected, you don't even need the hover stuff generated for the svgFill module. Here we use the fill attribute for a polygon, rectangle, circle and Jul 9, 2021 · tailwind css svg icon text center is not working Asked 4 years, 8 months ago Modified 4 years, 8 months ago Viewed 4k times Feb 20, 2026 · React Native does not have SVG components but universal SVG support can be achieved with 3rd party libraries such as react-native-svg. The only way I see to change color of SVG icon is Learn how to fix the Tailwind w-full not working issue with this step-by-step guide. Tailwind provides a range of built-in classes, along with the flexibility to use arbitrary values, enabling precise control over stroke thickness for SVG elements Nov 18, 2020 · Also the whole html body is not getting full width in medium and small screens. Tailwind CSS provides fill-color-value utilities to add fill to the SVGs. This class Utilities for controlling the background size of an element's background image. These attributes will automatically be applied to the underlying <svg> element. I'm in a NextJS environment using NextUI and tailwind css. By default, all icons have a color value of currentColor, a size value of 24px, and a stroke width of 2. logo-img path { fill: #000; } The above svg loads and is natively fill: #fff but when I use the above css to try change it to black it doesn't change, this is my first time playing with SVG and I am not sure why it's not working. This code so far just makes the outline of the star yellow. Utilities for controlling the style of an element's borders. Utilities for styling the stroke of SVG elements. This is just a shorthand for rotate-[var(<custom-property>)] that adds the var() function for you automatically. Check working demo. When i put to class field, for example: 'fill-blue-700', after compilation i cant see applied blue color on SVG Element. Utilities for controlling the bounding box of an element's background. Learn how to use responsive utility variants in Tailwind CSS to create adaptive user interfaces for different screen sizes and devices. Aug 19, 2024 · Besides, we can also pass regular properties such as stroke, fill, width and height of the <svg> to the Heroicon, which is assigned to the <svg> element. If you overrode the colors section in your theme, then this won't be available anymore. svg extension, so you can import them like any other JavaScript file. Jan 28, 2025 · Issue: Tailwind CSS IntelliSense Not Working in VS Code (v4) If you're using Tailwind CSS v4 and noticing that IntelliSense isn't suggesting class names properly, the issue might be related to the "tailwindCSS. This is just a shorthand for animate-[var(<custom-property>)] that adds the var() function for you automatically. Explore usage, conditional applications, and customization techniques. However, this is not a Tailwind problem, rather it is a restriction with how references in SVGs work in HTML in general – you would still see this problem without Tailwind. When I work with SVGs I make sure the viewBox is there before applying a width or height, having both will both display and control the size of the rendered SVG. items-stretch. This guide outlines the core usages, conditional applications, customization techniques, and more when working with Tailwind's fill utilities. config. Utilities for controlling the vertical alignment of an inline or table-cell box. Sep 28, 2025 · You might try setting the text-red-500 class, but the fill remains black. Jul 23, 2025 · As it is XML-based, you can easily edit or change the SVG icon colors with Tailwind. May 11, 2024 · Create a responsive navbar with a hamburger menu icon using Tailwind CSS and Alpine. Jun 13, 2021 · Then I can add another Tailwind class like dark:text-black, which should make the SVG black when the user enables dark mode. Every icon has a class attribute applied called lucide. This method allows you to treat SVGs as React components, making them easy to manipulate and style using React's capabilities. In this example, the fill is set to the current text color with fill-current. May 27, 2024 · Setting default font colors - svg fill currentColor not behaving as expected #13750 Closed Answered by wongjn Der-Alex asked this question in Help edited Jan 31, 2019 · This SVG filter will only impart color to icons with a white fill, so If we have an icon with a black fill, we can use invert() to convert it to white before applying the SVG filter. Responsive design. Covers all Tailwind colors for SVG icons, responsive fills, and dark mode support. Tailwind CSS SVG Fill Classes The following is the list of Tailwind CSS SVG Fill classes that provides an effective way of handling SVG element colors. Tailwind CSS is a utility-first CSS framework for rapidly building modern websites without ever leaving your HTML. <AiOutlineStar className="text-yellow-400" /> Changing the backgroundColor property only changes the box of the star. Use the fill-current utility to set the fill color to the current text color: Sep 4, 2023 · Tailwind will not recognize your fill-${color-var} class because it only works with explicitly defined classes in the config such as fill-primary, fill-red-600 . Sizing classes are working such as h-4 and w-4 but fill-current text-white does not change the fill color of the svg. Jul 16, 2021 · How to change the color of an svg element in Tailwind Asked 4 years, 7 months ago Modified 4 years, 6 months ago Viewed 2k times this is not a tailwind question, it’s a css question. Any suggestions? Learn how to use Tailwind CSS `fill` utilities to style SVG shapes effortlessly. If an SVG icon uses stroke lines, then fill-{color} will not give the correct result. bg-red-100#right-pane i haven’t tried it in the browser but the main thing here is items-stretch. experimental. by spamming h-full w-full on every flex item you’ll get very unpredictable results, they’ll be pushing each other away a lot. Nov 18, 2020 · Also the whole html body is not getting full width in medium and small screens. . Jan 26, 2025 · Furthermore, the second doesn't work because: bg-* arbitrary value class defaults to background-color if Tailwind can't determine the value type, as with CSS variables. Utilities for controlling an element's background image. May 17, 2022 · i am implementing a reponsive website with react and tailwind , i have an SVG image which i want to make it as a background image for a main tag but it doesn't work . Normally, if you do not set "width" and "height" of parent container, you wont see the image. The fill attribute is used to color the interior of an element, while the stroke is used to color the element's border. The value of the fill attribute can be a color name, rgb value or a hex value. What I don't understand is that I still haven't used any of the responsive classes from tailwindcss like md, sm or lg. Sep 28, 2016 · If you are not in control of your SVG, (perhaps because it comes from an external source you are re-theming,) you are stuck using !important to override the SVG fill property. Use fill-current to set the fill color of an SVG to the current text color. To make a proper SVG icon styled with Tailwind remove the stroke , fill and stroke-width attributes and use proper TailwindCSS utility classes instead: Utilities for styling the fill of SVG elements. mystar { fill: blue; } circle. What am I missing here? The solution for filling the height of the viewport with Tailwind CSS is to use the h-screen class. json. flex. If the SVG doesn't have a fill property, you can still use the fill property. js. Styling icons individually can be done by passing props to the icon component. mycircle { fill: green; } This works great, however I'm looking for a way to modify the "fill" attribute of an SVG when it's being served as a BACKGROUND-IMAGE. (Pic) My suggestion is to try using text class, or maybe you can provide your SVG. Trouble is that I can't set value (color) in fill property in Chrome, but in Firefox it works. Complete guide with examples and troubleshooting tips. js Image will take up all the "width" and "height" of the container parent element. mdpwz hso eylq dlltk knxu mcduoj eycxt xyivcu ytte fizc
Tailwind svg fill not working. fill-current to set the fill color of an SVG...Tailwind svg fill not working. fill-current to set the fill color of an SVG...