Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Components that behave like regular HTML elements #10667

Closed
CalebPena opened this issue Feb 29, 2024 · 2 comments
Closed

Components that behave like regular HTML elements #10667

CalebPena opened this issue Feb 29, 2024 · 2 comments

Comments

@CalebPena
Copy link

Describe the problem

When creating a library with components that extend the functionality of an HTML element, it is difficult to make the component behave like an HTML element. Idealy, the user would be able to use the component like a regual HTML element. For example, if you want to create a component that extends the functionality of an input to log the value every time that it changes, you would have to add CSS variables for every style of the input. That which would also require the user to look at the documentation every time they wanted to change a style.

<script>
  export let value;
  
  $: console.log(value);
</script>

<input {...$$restProps} bind:value>

<style>
  input {
    font-size: var(--font-size);
    width: var(--width);
    ...
  }
</style>

A more complicated example could be a Modal component where the component aims to add all of the accessibility stuff for the modal, but you want the user to be able to customize it however they want like it was a regular div.

Describe the proposed solution

It would be nice if the user could use some components like a regular HTML element.

Example:

<script extends="input">
  export let value;
  
  $: console.log(value);
</script>

<input {...$$restProps} bind:value>

You could then use the component like:

<CustomInput type="text" class="custom-input" value="hello" />

<style>
  .custom-input {
    background-color: pink;
  }
</style>

The advantage of this method is that the user does not have to know how to use your custom input, they just have to know how to use a regular HTML input.

Importance

nice to have

@Prinzhorn
Copy link
Contributor

My search for related issues brought up #8538 which also list more related issues.

@dummdidumm
Copy link
Member

Closing on favor of those issues linked

@dummdidumm dummdidumm closed this as not planned Won't fix, can't repro, duplicate, stale Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants