Skip to content

Tailwind intellisense support #78

Closed

Description

@nicholaswhittle

I'm trying to figure out the correct regex to use for intellisense support. Similar to tailwind-rn

vadimdemedes/tailwind-rn@2f848b6

What is the full regex pattern for tailwind-react-native-classnames to use with tailwindCSS.experimental.classRegex config?

Activity

  1. jaredh159 commented on Nov 4, 2021

    @jaredh159
    Owner

    I don't know honestly, but it shouldn't be too hard to come up with some regexes that work, for instance (not tested)

    "tailwindCSS.experimental.classRegex": [
      "tw`([^`]*)",
      "tw\\.style\\(([^)]*)\\)",
    ]
    

    etc... if you get it working, can you report back what you used?

  2. axeldelafosse commented on Nov 5, 2021

    @axeldelafosse

    I'm solving this by creating my own design system (View, Text and more) where the components are taking a tw prop.

    Then you can add tw to Tailwind CSS: Class Attributes VS Code extension setting to get IntelliSense working!

    For example:

    import { View, Text } from 'app/design-system';
    
    export function HelloWorld() {
      return (
        <View tw="flex-1 justify-center items-center bg-white dark:bg-black">
          <Text tw="text-black dark:text-white">
            Hello, World!
          </Text>
        </View>
      );
    }
    
  3. rickyalmeidadev commented on Nov 11, 2021

    @rickyalmeidadev

    I don't know honestly, but it shouldn't be too hard to come up with some regexes that work, for instance (not tested)

    "tailwindCSS.experimental.classRegex": [
      "tw`([^`]*)",
      "tw\\.style\\(([^)]*)\\)",
    ]
    

    etc... if you get it working, can you report back what you used?

    I've been using it for a few weeks and it's been working perfectly.

  4. nicholaswhittle commented on Nov 11, 2021

    @nicholaswhittle
    Author

    Great, my use case is getting it to work with emacs which isn't working with the same regex expression. When i figure it out il post it here.

  5. jaykay-p commented on Nov 13, 2021

    @jaykay-p

    @nicwhitts
    I ran into the same problem. I added classRegex in settings.json, but inteliisense didnt work.

    I got it working after installing tailwindcss and postcss 8 dependencies.
    Also, ran npx tailwindcss init command to create default tailwind.config.js in the root.

  6. Pedromdsn commented on Nov 13, 2021

    @Pedromdsn

    Estou resolvendo isso criando meu próprio sistema de design ( View, Texte mais), onde os componentes estão tomando uma twprop.

    Então você pode adicionar twa Tailwind CSS: Class Attributesconfiguração de extensão do VS Code para fazer o IntelliSense funcionar!

    Por exemplo:

    import { View, Text } from 'app/design-system';
    
    export function HelloWorld() {
      return (
        <View tw="flex-1 justify-center items-center bg-white dark:bg-black">
          <Text tw="text-black dark:text-white">
            Hello, World!
          </Text>
        </View>
      );
    }
    

    Great, the other alternatives don't work for me and that was going to be 10/10 to dispense with the workarounds.

  7. ahmed-rezk-dev commented on Nov 17, 2021

    @ahmed-rezk-dev

    I was looking to do the same. I found this solution. I use Neovim and it works great.

    For VScode:

    "scss.validate": false,
    "editor.quickSuggestions": {
        "strings": true
    },
    "editor.autoClosingQuotes": "always",
    "tailwindCSS.experimental.classRegex": [
        "tw`([^`]*)", // tw`...`
        "tw=\"([^\"]*)", // <div tw="..." />
        "tw={\"([^\"}]*)", // <div tw={"..."} />
        "tw\\.\\w+`([^`]*)", // tw.xxx`...`
        "tw\\(.*?\\)`([^`]*)" // tw(Component)`...`
    ],
    "tailwindCSS.includeLanguages": {
      "typescript": "javascript",
      "typescriptreact": "javascript"
    }
    

    For Neovim LSP:

    require"lspconfig".tailwindcss.setup {
      settings = {
        tailwindCSS = {
          experimental = {
            classRegex = {
              "tw`([^`]*)", -- tw`...`
              "tw=\"([^\"]*)", -- <div tw="..." />
              "tw={\"([^\"}]*)", -- <div tw={"..."} />
              "tw\\.\\w+`([^`]*)", -- tw.xxx`...`
              "tw\\(.*?\\)`([^`]*)"
            }
          }
        }
      }
    }
    

    Source: https://githubmemory.com/repo/kabouzeid/nvim-lspinstall/issues/45

  8. arnabtarwani commented on Dec 3, 2021

    @arnabtarwani

    You could also add style in the extensions under TailwindCSS extension Tailwind CSS IntelliSense in VS Code Settings (UI)

    image

  9. Repository owner locked and limited conversation to collaborators on Feb 1, 2022
  10. converted this issue into a discussion #124 on Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions