Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:
- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
can i get a user's dark mode setting via API?
It would be cool to make an app always match the Onshape ui without having to control it two places.
Answers
-
You can pull the theming for a user with /users/settings where "theme" 0 = light and 1 = dark. But this only applies to the users Preferences. If they change it for a particular document they are currently in, it might not work.
1 -
Thanks, Tabetha! I know I've seen other apps that will change if I just change the user setting so maybe that's how its done
0 -
hey! it's @tabetha_bulnes! 👋😎
This should work for getting the current browser tab's onshape theme:Navigation.Uri.Contains("theme=dark");
▚▞▚▞▚▞▚▞▚1 -
Building on Tabetha's and Michael's answers: Onshape gives the iframe both pieces, so you don't need the API call.
On load: the iframe URL carries
theme=darkortheme=light(Michael's approach). It's whatever theme you're viewing right now, including the quick toggle in the account menu./users/settingsonly has the saved preference, which is why it can miss that toggle.While open: Onshape posts
{ messageName: 'onshapeThemeChanged', theme: 'dark' | 'light' }to the iframe whenever the theme changes, whether from the toggle or the saved setting. The catch is that Onshape doesn't post anything to your iframe until your app sendsapplicationInitfirst.const q = new URLSearchParams(location.search); const apply = (theme) => { document.body.dataset.theme = theme; /* redraw canvases etc. */ }; apply(q.get('theme') === 'light' ? 'light' : 'dark'); const origin = new URL(q.get('server')).origin; // not hard-coded: enterprise domains differ window.addEventListener('message', (e) => { if (e.source !== window.parent || e.origin !== origin) return; if (e.data?.messageName === 'onshapeThemeChanged') apply(e.data.theme); }); window.parent.postMessage({ messageName: 'applicationInit', documentId: q.get('documentId'), workspaceId: q.get('workspaceId'), elementId: q.get('elementId'), }, origin);This is what my Form Studio app does. It works for element tabs and panel extensions; for an extension, put documentId, workspaceId and elementId in your action URL so you have them to send. I haven't seen
onshapeThemeChangedin the public docs (Claude found it in Onshape's client code), so it could change.1
Categories
- All Categories
- 10.2K Community Support
- 4.6K General
- 194 Account and subscriptions
- 353 Data management
- 1.6K Product Feedback
- 215 New in Onshape
- 14 Onshape Labs
- 75 CAM Studio
- 35 PCB Studio
- 107 Simulation
- 209 Onshape Mobile
- 315 App Store & Partners Apps
- 8.2K Using Onshape
- 1.8K Drawings
- 2.3K FeatureScript
- 324 Learning Center
- 253 Education Community



