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.

Attributify's attribute `align` doesn't work in SolidJS's `<div>` element

See original GitHub issue

As the title says, I tried to use the align attribute on the <div> element in SolidJS, but it didn’t work.

// App.tsx
function App() {
  return (
    <div h="50px" flex="~" justify="around" align="items-center">
      <div>Box 1</div>
      <div>Box 2</div>
      <div>Box 3</div>
    </div>
  );
}

export default App;

Maybe because the align attribute is an attribute of the HTMLDivElement, I added the align attribute into the ignoreAttributes list, and used the un-align instead, but still not working.

// vite.config.ts
import { defineConfig } from 'vite';
import solidPlugin from 'vite-plugin-solid';
import unocssPlugin from 'unocss/vite';
import presetUno from '@unocss/preset-uno';
import presetAttributify from '@unocss/preset-attributify';

export default defineConfig({
  plugins: [
    solidPlugin(),
    unocssPlugin({
      presets: [
        presetUno(),
        presetAttributify({ ignoreAttributes: ['align'] }),
      ],
    }),
  ],
  server: {
    port: 3000,
  },
  build: {
    target: 'esnext',
  },
});
// App.tsx
function App() {
  return (
    <div h="50px" flex="~" justify="around" un-align="items-center">
      <div>Box 1</div>
      <div>Box 2</div>
      <div>Box 3</div>
    </div>
  );
}

export default App;

This is the reproduction link: https://stackblitz.com/edit/reproduce-uno-solid-attributify-bug?file=src%2FApp.jsx,vite.config.js

Is this an UnoCSS bug? If it is, I’m more than willing to fix it, and need some guidance.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
zyyvcommented, Oct 13, 2022

In fact, @unocss/preset-attributify only extract code to generate tokens, more parsed power depends on unocss engine and base on those rules that comes from @unocss/preset-uno .

from the user’s point of view, are there any splits?

I don’t think I’m equipped to answer this question😅

1reaction
zyyvcommented, Oct 13, 2022

I didn’t see the reply in time, one step faster than you. If I don’t solve it well, you can send a new pr

Read more comments on GitHub >

github_iconTop Results From Across the Web

Boolean attributes · Issue #1101 · solidjs/solid - GitHub
Current behavior in Solid: Assume const Div = (props) => <... ... JSX attributes foo and foo={true} behave for an HTML element, as...
Read more >
Documentation - SolidJS · Reactive Javascript Library
The createSignal function returns a pair of functions as a two-element array: a getter (or accessor) and a setter. In typical use, you...
Read more >
Bindings/Refs - SolidJS · Reactive Javascript Library
You can always get a reference to a DOM element in Solid through assignment, since JSX creates actual DOM elements. For example: const...
Read more >
Guides:Rendering - SolidJS · Reactive Javascript Library
The majority of all attributes on native element JSX are set as DOM attributes. Static values are built right into the template that...
Read more >
Bindings/Forwarding Refs - SolidJS · Reactive Javascript Library
The way we do this is still by using the ref attribute. From the outside, using ref on a component works very similar...
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