Style
tsx
export default function Rootfunction Root(): JSX.Element
() { return (
<Html(alias) function Html(props: ComponentProps<"html">): JSX.Element
import Html
lang(property) JSX.HTMLAttributes<HTMLHtmlElement>.lang?: string | undefined
="en"> <Head(alias) function Head(props: ComponentProps<"head">): JSX.Element
import Head
> <Style(alias) const Style: Component<JSX.StyleHTMLAttributes<HTMLStyleElement>>
import Style
>{` p {
color: #26b72b;
}
`}</Style(alias) const Style: Component<JSX.StyleHTMLAttributes<HTMLStyleElement>>
import Style
> </Head(alias) function Head(props: ComponentProps<"head">): JSX.Element
import Head
> </Html(alias) function Html(props: ComponentProps<"html">): JSX.Element
import Html
> );
}
tsx
export default function Rootfunction Root(): JSX.Element
() { return (
<Html(alias) function Html(props: ComponentProps<"html">): JSX.Element
import Html
lang(property) JSX.HTMLAttributes<HTMLHtmlElement>.lang?: string | undefined
="en"> <Head(alias) function Head(props: ComponentProps<"head">): JSX.Element
import Head
> <Style(alias) const Style: Component<JSX.StyleHTMLAttributes<HTMLStyleElement>>
import Style
>{` p {
color: #26b72b;
}
`}</Style(alias) const Style: Component<JSX.StyleHTMLAttributes<HTMLStyleElement>>
import Style
> </Head(alias) function Head(props: ComponentProps<"head">): JSX.Element
import Head
> </Html(alias) function Html(props: ComponentProps<"html">): JSX.Element
import Html
> );
}
The Style
component contains css used to style the page. Generally, it is better to put styles in an external stylesheet and use a Link
instead. It is a wrapper of the style
element and is a re-export from @solidjs/meta
. Note styles provided to the Style
component are not scoped.
Style
components can not only be added to Head
but also across your application allowing dynamic addition and removal depending on if currently mounted.
tsx
export default function MyPagefunction MyPage(): JSX.Element
() { return (
<>
<Style(alias) const Style: Component<JSX.StyleHTMLAttributes<HTMLStyleElement>>
import Style
>{` p {
color: #909090;
}
`}</Style(alias) const Style: Component<JSX.StyleHTMLAttributes<HTMLStyleElement>>
import Style
> <h1(property) JSX.IntrinsicElements.h1: JSX.HTMLAttributes<HTMLHeadingElement>
>My Super Cool Page</h1(property) JSX.IntrinsicElements.h1: JSX.HTMLAttributes<HTMLHeadingElement>
> </>
);
}
tsx
export default function MyPagefunction MyPage(): JSX.Element
() { return (
<>
<Style(alias) const Style: Component<JSX.StyleHTMLAttributes<HTMLStyleElement>>
import Style
>{` p {
color: #909090;
}
`}</Style(alias) const Style: Component<JSX.StyleHTMLAttributes<HTMLStyleElement>>
import Style
> <h1(property) JSX.IntrinsicElements.h1: JSX.HTMLAttributes<HTMLHeadingElement>
>My Super Cool Page</h1(property) JSX.IntrinsicElements.h1: JSX.HTMLAttributes<HTMLHeadingElement>
> </>
);
}