question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

form input styles doesn't work properly

See original GitHub issue

Form input styles doesn’t work properly, sometimes it works, sometimes it doesn’t and sometimes it works partially. Tested with the latest version of windicss + svelte-windicss-preprocess on the latest version of SvelteKit and Sapper.

How to reproduce the issue: 1 - set all the files listed below 2 - $ npm run dev 3 - manually refresh the page 4 - $ npm run build && npm run start 5 - manually refresh the page

svelte.config.cjs:

const sveltePreprocess = require('svelte-preprocess');
module.exports = {
  preprocess: [
    sveltePreprocess.typescript(),
    require('svelte-windicss-preprocess').preprocess({
      config: 'tailwind.config.cjs',
      compile: true,
      prefix: 'css-',
      globalPreflight: true,
      globalUtility: true,
    }),
  ],
  kit: {
    adapter: '@sveltejs/adapter-node',
    target: '#svelte'
  }
};

tailwind.config.cjs:

module.exports = {
  purge: [],
  darkMode: false, // or 'media' or 'class'
  theme: {
    extend: {},
  },
  variants: {
    extend: {},
  },
  plugins: [
    require('windicss/plugin/forms')
  ],
}

src/components/Input.svelte:

<script>
  let css;
  export { css as class };
  export let placeholder;
</script>

<input type="text" {placeholder} class="{css} border-gray-300 focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 rounded-md shadow-sm" />

src/routes/index.svelte:

<script>
  import Input from '$components/Input.svelte';
</script>

<form action="">
  <Input placeholder="component-input" class="block mt-1 ml-1 w-56" />
  <input type="text" placeholder="normal-input" class="block mt-1 ml-1 w-56 border-gray-300 focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 rounded-md shadow-sm" />
</form>

screenshots:

svelte-windicss-issue-1 svelte-windicss-issue-2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
alexanderniebuhrcommented, Feb 24, 2021

closing this in favor of https://github.com/windicss/svelte-windicss-preprocess/issues/32 as this is not special to this case, but seems to be generic to plugins

1reaction
prab-itcommented, Feb 24, 2021

@alexanderniebuhr ok, let’s see if we can come up with a better solution. Thanks for your support! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Input box style not working properly - css - Stack Overflow
I have centered my registration form. I have ...
Read more >
Styling Form Inputs in CSS With :required, :optional, :valid and
We can use the :required , :optional , :valid and :invalid pseudo-classes coupled with HTML5 form validation attributes like required or pattern ...
Read more >
How to style forms with CSS: A beginner's guide
You should now understand how to style simple form elements and how to use custom controls when browser input fields are difficult to...
Read more >
6 Reasons - HTML5 Required Attribute Validation not Working
If the input elements aren't inside a form tag then HTML5 required attribute will fail to work. So always put input tags inside...
Read more >
CSS Forms - W3Schools
CSS Forms · Styling Input Fields · Padded Inputs · Bordered Inputs · Colored Inputs · Focused Inputs · Input with icon/image ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found