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

Feature-request: Tabs, listen for programmatic change in value #31

Open
dRAT3 opened this issue Sep 28, 2021 · 1 comment
Open

Feature-request: Tabs, listen for programmatic change in value #31

dRAT3 opened this issue Sep 28, 2021 · 1 comment

Comments

@dRAT3
Copy link

dRAT3 commented Sep 28, 2021

I am changing the bind:active value with a button, but the tab doesn't become active.

@Antfere
Copy link

Antfere commented Nov 26, 2022

A fix for this would be to manually set the "tabid" prop for each "Tab" component, then in the "Tabs" component which wraps the "Tab" components you "bind:progVar" where progVar is your programmatic variable which can then be used in your svelte scripts. I set up the logic to connect a url router to the tabs in a navbar like so:

<script>
let progVar = "/";
$: progVar = location.pathname
// Whenever the url in the browser changes this value will change, dynamically updating progVar
</script>

<Nav>
  <svelte:fragment slot="left">
    <Tabs bind:progVar>
      <Tab on:click={() => location.pathname = "/a"} tabid="/a">A</Tab>
      <Tab on:click={() => location.pathname = "/b"} tabid="/b">B</Tab>
      <Tab on:click={() => location.pathname = "/c"} tabid="/c">C</Tab>
    </Tabs>
  </svelte:fragment>
</Nav>

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

2 participants