FrameSelection - headless drag-to-select component + composable #1317
                  
                    
                      michaelbany
                    
                  
                
                  started this conversation in
                Ideas
              
            Replies: 0 comments
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
Hey! I wanted to share a small utility I’ve been using across some of my apps — it’s a headless component + composable pair that enables selecting items using a drag rectangle (like in file explorers).
I designed it to be extremely simple and plug-and-play. Here's how it looks in practice:
You simply wrap the block of items and you get this behavior:
I also pair it with a composable called
useSelect()which handles selection logic like ctrl/cmd toggles, shift range selection, and general state management. It’s fully decoupled from the DOM or item structure — just a generic utility to manage selectedItems.You can combine the composable with the frame component like this:
Would this kind of thing be a good fit as a shadcn-vue utility or extension?
I know it's not a Radix UI primitive, but I figured this pattern could be useful for things like file managers, table UIs, asset galleries, and similar use cases.
Let me know what do you think!
Here are the links to the component and composable.
Feel free to clone the repo - there are a few other experiments in there that extend or complement the shadcn/radix stack. You might find something useful or inspiring. 😄
Cheers;
Beta Was this translation helpful? Give feedback.
All reactions