with one click
solidjs-component
// Applies project conventions for Solid.js component structure, naming, state, and styling. Use when writing or editing .tsx component files.
// Applies project conventions for Solid.js component structure, naming, state, and styling. Use when writing or editing .tsx component files.
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | solidjs-component |
| description | Applies project conventions for Solid.js component structure, naming, state, and styling. Use when writing or editing .tsx component files. |
See rules/file-naming-rules.md
See rules/component-basic-structure.md
See rules/component-state-structure.md
See rules/component-initial-prop.md
See rules/component-variable-name.md
See rules/component-signal-empty-value.md
class strings (cx)See rules/component-class-cx.md
ref)Default: createSignal + ref={setElement} for DOM handles—matches this repo and satisfies Oxlint no-unassigned-vars (explicit assignment).
import {createSignal} from 'solid-js'
function Example() {
const [el, setEl] = createSignal<HTMLDivElement | undefined>()
const handleClick = () => el()?.focus()
return <div ref={setEl} onClick={handleClick} />
}
Keep refs inside the component and lift only the values and events the parent needs. Do not pass the DOM through a ref prop; pass what the parent needs through callbacks at the appropriate time (e.g. click, toggle).
on*)See rules/component-event-callback-naming.md
Use SolidJS built-in control-flow components from solid-js instead of ad-hoc &&, nested ternaries, or .map() when you need reactive branching or keyed lists:
<Show> (when, optional fallback)<Switch> with <Match> children (when per branch)<For> (each, keyed item tracking)Implement proper code splitting but never split Solidjs props
BAD (breaks reactivity by splitting props):
interface Props {
count: number
}
export function Counter(props: Props) {
const {count} = props
return <div>{count}</div>
}
GOOD (keep props reactive):
interface Props {
count: number
}
export function Counter(props: Props) {
return <div>{props.count}</div>
}
If splitting is unavoidable, use Solid's splitProps:
import {splitProps} from 'solid-js'
interface Props {
count: number
class?: string
}
export function Counter(props: Props) {
const [local, rest] = splitProps(props, ['count', 'class'])
return (
<div class={local.class} {...rest}>
{local.count}
</div>
)
}
In Solid, createEffect cleanup must use onCleanup(() => ...) inside the effect (do not return a cleanup function)
BAD (do not return a cleanup function):
import {createEffect} from 'solid-js'
export function Example() {
createEffect(() => {
const id = window.setInterval(() => {}, 1000)
return () => window.clearInterval(id)
})
return null
}
GOOD (use onCleanup inside the effect):
import {createEffect, onCleanup} from 'solid-js'
export function Example() {
createEffect(() => {
const id = window.setInterval(() => {}, 1000)
onCleanup(() => window.clearInterval(id))
})
return null
}
official documentation links -> ./references/reference.md