Giter Club home page Giter Club logo

tailwindcss-intellisense's Introduction

Tailwind CSS IntelliSense enhances the Tailwind development experience by providing Visual Studio Code users with advanced features such as autocomplete, syntax highlighting, and linting.

Installation

Install via the Visual Studio Code Marketplace →

In order for the extension to activate you must have tailwindcss installed and a Tailwind config file named tailwind.config.{js,cjs,mjs,ts} in your workspace.

Features

Autocomplete

Intelligent suggestions for class names, as well as CSS functions and directives.

Linting

Highlights errors and potential bugs in both your CSS and your markup.

Hover Preview

See the complete CSS for a Tailwind class name by hovering over it.

Tailwind CSS Language Mode

An alternative to VS Code's built-in CSS language mode which maintains full CSS IntelliSense support even when using Tailwind-specific at-rules. Syntax definitions are also provided so that Tailwind-specific syntax is highlighted correctly in all CSS contexts.

Recommended VS Code Settings

files.associations

Use the files.associations setting to tell VS Code to always open .css files in Tailwind CSS mode:

"files.associations": {
  "*.css": "tailwindcss"
}

editor.quickSuggestions

By default VS Code will not trigger completions when editing "string" content, for example within JSX attribute values. Updating the editor.quickSuggestions setting may improve your experience:

"editor.quickSuggestions": {
  "strings": "on"
}

Extension Commands

Tailwind CSS: Show Output

Reveal the language server log panel. This command is only available when there is an active language server instance.

Tailwind CSS: Sort Selection (pre-release)

When a list of CSS classes is selected this command can be used to sort them in the same order that Tailwind orders them in your CSS. This command is only available when the current document belongs to an active Tailwind project and the tailwindcss version is 3.0.0 or greater.

Extension Settings

tailwindCSS.includeLanguages

This setting allows you to add additional language support. The key of each entry is the new language ID and the value is any one of the extensions built-in languages, depending on how you want the new language to be treated (e.g. html, css, or javascript):

{
  "tailwindCSS.includeLanguages": {
    "plaintext": "html"
  }
}

tailwindCSS.files.exclude

Configure glob patterns to exclude from all IntelliSense features. Inherits all glob patterns from the files.exclude setting. Default: ["**/.git/**", "**/node_modules/**", "**/.hg/**", "**/.svn/**"]

tailwindCSS.emmetCompletions

Enable completions when using Emmet-style syntax, for example div.bg-red-500.uppercase. Default: false

tailwindCSS.classAttributes

The HTML attributes for which to provide class completions, hover previews, linting etc. Default: class, className, ngClass, class:list

tailwindCSS.colorDecorators

Controls whether the editor should render inline color decorators for Tailwind CSS classes and helper functions. Default: true

Note that editor.colorDecorators must be enabled for color decorators to be shown.

tailwindCSS.showPixelEquivalents

Show px equivalents for rem CSS values in completions and hovers. Default: true

tailwindCSS.rootFontSize

Root font size in pixels. Used to convert rem CSS values to their px equivalents. See tailwindCSS.showPixelEquivalents. Default: 16

tailwindCSS.hovers

Enable hovers. Default: true

tailwindCSS.suggestions

Enable autocomplete suggestions. Default: true

tailwindCSS.codeActions

Enable code actions. Default: true

tailwindCSS.validate

Enable linting. Rules can be configured individually using the tailwindcss.lint settings:

  • ignore: disable lint rule entirely
  • warning: rule violations will be considered "warnings," typically represented by a yellow underline
  • error: rule violations will be considered "errors," typically represented by a red underline

tailwindCSS.lint.invalidScreen

Unknown screen name used with the @screen directive. Default: error

tailwindCSS.lint.invalidVariant

Unknown variant name used with the @variants directive. Default: error

tailwindCSS.lint.invalidTailwindDirective

Unknown value used with the @tailwind directive. Default: error

tailwindCSS.lint.invalidApply

Unsupported use of the @apply directive. Default: error

tailwindCSS.lint.invalidConfigPath

Unknown or invalid path used with the theme helper. Default: error

tailwindCSS.lint.cssConflict

Class names on the same HTML element which apply the same CSS property or properties. Default: warning

tailwindCSS.lint.recommendedVariantOrder

Class variants not in the recommended order (applies in JIT mode only). Default: warning

tailwindCSS.inspectPort

Enable the Node.js inspector agent for the language server and listen on the specified port. Default: null

Experimental Extension Settings

Experimental settings may be changed or removed at any time.

tailwindCSS.experimental.configFile

Default: null

By default the extension will automatically use the first tailwind.config.{js,cjs,mjs,ts} file that it can find to provide Tailwind CSS IntelliSense. Use this setting to manually specify the config file(s) yourself instead.

If your project contains a single Tailwind config file you can specify a string value:

"tailwindCSS.experimental.configFile": ".config/tailwind.config.js"

For projects with multiple config files use an object where each key is a config file path and each value is a glob pattern (or array of glob patterns) representing the set of files that the config file applies to:

"tailwindCSS.experimental.configFile": {
  "themes/simple/tailwind.config.js": "themes/simple/**",
  "themes/neon/tailwind.config.js": "themes/neon/**"
}

Troubleshooting

If you’re having issues getting the IntelliSense features to activate, there are a few things you can check:

  • Ensure that you have a Tailwind config file in your workspace and that this is named tailwind.config.{js,cjs,mjs,ts}. Check out the Tailwind documentation for details on creating a config file.
  • Ensure that the tailwindcss module is installed in your workspace, via npm, yarn, or pnpm.
  • Make sure your VS Code settings aren’t causing your Tailwind config file to be hidden/ignored, for example via the files.exclude or files.watcherExclude settings.
  • Take a look at the language server output by running the Tailwind CSS: Show Output command from the command palette. This may show errors that are preventing the extension from activating.

tailwindcss-intellisense's People

Contributors

43081j avatar alexbjorlig avatar bradlc avatar choplin avatar danmichaelo avatar dansnow avatar dcalhoun avatar dependabot[bot] avatar dhc02 avatar dorgelesnzi avatar flostellbrink avatar guillaumebriday avatar hampustagerud avatar ignacemaes avatar joshprice avatar ledenis avatar lucasvazq avatar mattwaler avatar maximilianlloyd avatar merrickluo avatar mopamo avatar mskelton avatar neupauer avatar nulty avatar praveenperera avatar reinink avatar remcohaszing avatar robinmalfait avatar thecrypticace avatar therealsyler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tailwindcss-intellisense's Issues

Emmet Suggestions

I am loving the plugin. It has really helped me writting tailwind css.

Just a thought I had was I like to write emmet abbrivations.
eg.
div.m-5.p-5
Turns into
<div class="m-5 p-5"></div>

It would be great if while writting emmet code we could gett tailwind suggestions. I understand this might be a difficult thing to implement but I think it would be so awesome.

Vue <style></style> support

Awesome plugin thank you !
Could it be possible to also support styles written in <style></style> markup in .vue files ?

Great job !

Not working, I don't have any auto-completion, and CSS preview

I had installed it and it works perfectly, but it stopped auto-completion, and CSS preview.

Any idea what it might be? I have already tried reinstalling and nothing, this extension is very useful I really want to continue using.

  • I use the latest version of Tailwind

@screen autocomplete

Second feature request from me. :)

It would be awesome to get the same kind of autocomplete that we get with @apply but with Tailwind's @screen directive. It would list all the screens defined in the Tailwind config.

Thanks again!

The extension is very picky on when to show suggestions

Problem

The extension is very picky on when to show suggestions. I have recorded a small demo reproducing the problem. When you write the class name, everything works as expected. If you delete one character at a time it also works as expected. If you remove a whole word using alt+backspace (in US layout the equivalent is option+delete) it stops showing the suggestions and it's really hard to invoke it back.

Platform

  • VS Code Version 1.34.0
  • Tailwind IntelliSense version 0.2.0
  • MacOS version 10.14.4

Class name formatting

Example:

<div class="xl:text-center md:text-left lg:text-right mx-auto"></div>

Would become:

<div class="mx-auto md:text-left lg:text-right xl:text-center"></div>

Class names could be ordered by variant and/or CSS property.

  1. What settings should be exposed for this?
  2. What should be done with unknown (non-Tailwind) class names?

Completion for tw`...` is no more?

Hi. I just upgraded my app to Tailwind v1. Followed the migration guides to the letter. And now I'm left without autocompletion in the tw... (your babel plugin - babel-plugin-tailwind-components).

Can anyone give me any suggestion on how to get them back?

Not able to get it working

Hey there, this looks awesome, I saw it from you posting it in the Tailwind slack!

So far I'm unable to get it working. In my case, my tailwind.js is in web/themes/custom/theme/tailwind.js and I'm testing using various filename.html.twig files inside web/themes/custom/theme/templates and it just doesn't seem to be doing anything. I don't see any autocomplete popup when typing class names.

I tried renaming the file to filename.twig or even filename.html (even though Twig seems to be supported, looking at https://github.com/bradlc/vscode-tailwindcss/blob/master/src/extension.ts#L18) just in case and that didn't help. None of them give me any kind of autocomplete for classes.

Any thoughts on what I could be missing? Or any info I could provide to help debug?

Thanks!

No CSS preview while typing classes (in HTML and CSS)

I am looking at the animated screenshots in the extension's description, and I see that as you're typing Tailwind classes in HTML or in CSS (following @apply) you see the corresponding CSS declaration next to the highlighted class in the IntelliSense popup. It doesn't work for me though:

no-css

no-css-2

I should see background-attachment: fixed; next to bg-fixed, but there's nothing there.

Auto Opens Suggestions in TSX

The default behaviour of the suggestions in TSX is to open when you start typing. For some reason when I enable vscode-tailwindcss the suggestions open immediately and are missing the props for my React components. On the attached gif I am showing how it automatically opens the suggestions with missing props. Then I hit esc and then ctrl+space to open the suggestions again and my props are there.

vscode-tailwindcss-bug

I think ideally it would auto-open with the props there. Or if an option in the config could be added to disabled the automatic opening.

This extension is the reason I switched to VSCode, and I love it, so thanks for making it. For now I can work around the issue with just a couple extra keystrokes.

Not working for HTML-like files

Thanks for the great extension.

For regular HTML files, it works great. However, the extension stops working completely once a file is associated via VSCode to another file type.

For example, Django template files use the regular .html extension but include special mustache {{ }} syntax. I'm using another extension to get tag highlighting for these files, as well as emmet expansion. But once I associate this file as "Django HTML" - TailwindCSS Intellisense stops working.

Anything I'm missing?

Theme

What is that theme in those gifs? I want to get those custom fonts on html tag's properties

Lint-er Giving Syntax Error after @apply

Issue: CSS Lint-er returns syntax error .

Tried:

  • Adding, removing dot before Applied Classes;
  • Disabling, enabling the extension;
  • Restarting VSCode

Syntax highlighting seems to occur as expected.

image

image

Syntax highlighting

First of all, thank you so much for this.

It would be cool if not only the linter didn't mark Tailwind's "additions" to CSS as invalid (for instance it doesn't like @apply .some-class, complaining with [css] identifier expected), but to go one step further and highlight @apply and the utilities following it. Similarly, config() could be highlighted the same way other CSS "functions" such as calc() are.

I don't know if that's possible, but if it is, it would make this awesome extension even better. :) Thanks!

EDIT: I forgot to mention @tailwind and @screen.

Autocomplete @apply classes without prepending with a dot

Hi there,

Many thanks for this time-saving extension.

Why does it prepend autocompleted classes with a dot although it's not required according to the docs? Is it done on purpose? Could we have an option to disable it?

Current output:

.btn {
  @apply .font-bold .py-2 .px-4 .rounded;
}

Expected output:

.btn {
  @apply font-bold py-2 px-4 rounded;
}

Thanks!

Make tailwind.css configurable?

Thank you for this awesome plugin!

Reading #1 I already found out why it does not work for me:

I use an ember plugin, which stores tailwind in a particular location and also splits the config file in multiple files.

Do you need the .js to make this work, or would the output location of the compiled css be enough? In this case, if you could make this location configurable that would help me a lot!

The css intellisense plugin works fairly well for me but does not properly detect sm:, active: and so on

Not working, I don't have any suggestions.

Issue Type: Bug

Hi!

I have a Wordpress project, I have the project root in the Wordpress root folder, but Tailwind CSS is installed in the /wp-content/theme/theme-name/ subfolder using Yarn.

I don't have class name suggestions in any file (HTML, PHP, CSS, SCSS) and I'm not sure why. Everything else is working as expected.

Extension version: 0.1.16
VS Code version: Code 1.33.1 (51b0b28134d51361cf996d2f0a1c698247aeabd8, 2019-04-11T08:27:14.102Z)
OS version: Windows_NT x64 10.0.17763

System Info
Item Value
CPUs Intel(R) Core(TM) i7-3630QM CPU @ 2.40GHz (8 x 2395)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
surface_synchronization: enabled_on
video_decode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 23.89GB (12.90GB free)
Process Argv
Screen Reader no
VM 0%

Not working when using the CDN version

Hi! I'm using the Tailwind CDN version so I don't have it installed as a npm package nor have a Tailwind config file. How can I make it work? Thanks!

Autocomplete not working on literal strings

Say i need some variables on the prop className on React. I would want to use a es6 literal string

<div className={`font-bold text-sm text-gray-600 hover:text-white ${className}`} />

The plugin doesn't show any suggestions, even with Ctrl+Space. But it works just fine with

<div className="font-bold text-sm text-gray-600 hover:text-white"  />

Support for .leaf files

First, thank you for this awesome extension.

Could you add support for .leaf files, which are used for templates in Vapor applications?
https://github.com/vapor/leaf

If I rename a .leaf file to .html, everything works as expected.

Thank you 👍

*.scss files support?

Looking into extension's configuration files tailwind.tmLanguage.json seems that .scss files should be supported. However, @apply and @tailwind commands ale not recognized by editor within them (and highligted as an error). Tailwind autocomplete is also not available. .css files work just fine.

If .scss files are not currently supported afterall pls consider this a feature request.

image

  • Extension Name: vscode-tailwindcss
  • Extension Version: 0.1.12
  • OS Version: Darwin x64 18.0.0
  • VSCode version: 1.28.2
{
	"activationTimes": {
		"startup": true,
		"codeLoadingTime": 258,
		"activateCallTime": 0,
		"activateResolvedTime": 1315,
		"activationEvent": "workspaceContains:**/{tailwind,tailwind.config,tailwind-config,.tailwindrc}.js"
	}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.