Skip to content

Support Style Props for Svelte #2282

Description

@devunt

Description

Currently Panda CSS only supports style props for jsx-based components.
This request proposes style props support for svelte components.

Problem Statement/Justification

Component.svelte

<script lang="ts">
  import { css } from '$styled-system/css';
  import type { SystemStyleObject } from '$styled-system/types';

  let cssProp: SystemStyleObject | undefined = undefined;
  export { cssProp as css };
</script>

<div class={css(cssProp)} />

+page.svelte

<script lang="ts">
  import Component from './Component.svelte';
</script>

<Component css={{ color: 'red' }} />

This code renders following markup, but no corresponding styles are generated.

<div class="text_red" />

Panda generator does not see this as a token references, in contrast to what it does to jsx components.

Proposed Solution or API

Please support svelte component props like mentioned above.

Alternatives

Use css.raw as it forcefully make Panda generator to recognize it as a tokens.
But it is somewhat tedious to use css.raw everywhere.

+page.svelte

<script lang="ts">
  import { css } from '$styled-system/css';
  import Component from './Component.svelte';
</script>

<Component css={css.raw({ color: 'red' })} />

Additional Information

No response

Activity

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions