{"id":16784749,"url":"https://github.com/mattzque/bevy-ui-string-parser","last_synced_at":"2026-05-08T13:03:50.464Z","repository":{"id":220387580,"uuid":"751538688","full_name":"mattzque/bevy-ui-string-parser","owner":"mattzque","description":"Parser for various values used in bevy-ui.","archived":false,"fork":false,"pushed_at":"2024-02-02T16:24:18.000Z","size":39,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-15T11:27:35.822Z","etag":null,"topics":["bevy","bevy-ui","css"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/bevy_ui_string_parser","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattzque.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-02-01T20:05:00.000Z","updated_at":"2024-02-01T20:58:54.000Z","dependencies_parsed_at":"2025-06-06T19:31:59.371Z","dependency_job_id":null,"html_url":"https://github.com/mattzque/bevy-ui-string-parser","commit_stats":null,"previous_names":["mattzque/bevy-ui-string-parser"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mattzque/bevy-ui-string-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattzque%2Fbevy-ui-string-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattzque%2Fbevy-ui-string-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattzque%2Fbevy-ui-string-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattzque%2Fbevy-ui-string-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattzque","download_url":"https://codeload.github.com/mattzque/bevy-ui-string-parser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattzque%2Fbevy-ui-string-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32781566,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"ssl_error","status_checked_at":"2026-05-08T08:22:45.650Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bevy","bevy-ui","css"],"created_at":"2024-10-13T08:07:04.139Z","updated_at":"2026-05-08T13:03:50.436Z","avatar_url":"https://github.com/mattzque.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bevy-UI String Parser Utilities\n\n![License](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)\n[![Crates.io](https://img.shields.io/crates/v/bevy_ui_string_parser.svg)](https://crates.io/crates/bevy_ui_string_parser)\n[![Docs](https://docs.rs/bevy/badge.svg)](https://docs.rs/bevy_ui_string_parser/latest/bevy_ui_string_parser/)\n\nThis rust crate provides a set of parsing functions that can be used to\nconvert strings into various bevy-ui types like `Color`, `Val` or `UiRect`.\nThe syntax matches CSS, but it doesn't try to replicate it perfectly.\n\nIt depends on the [nom](https://crates.io/crates/nom) library for parsing.\n\n## Parsers\n\n### Color\n\nParses Color values, such as `#f0f` or `yellow`.\n\n```rust\nuse bevy::render::color::Color;\nuse bevy_ui_string_parser::color_string_parser;\nlet color: Option\u003cColor\u003e = color_string_parser(\"#f00\");\nassert_eq!(color, Some(Color::RED));\n```\n\n#### Supported syntax\n\n* `red`, `blue` -\u003e css color names (see https://drafts.csswg.org/css-color/#named-colors)\n* `#f0f`, `#ff00ff` -\u003e hex color (3 or 6 digits)\n* `#ff00ff00` -\u003e hex color with alpha (8 digits)\n* `rgb(1.0, 0.0, 0.0)` -\u003e rgb color (0.0-1.0)\n* `rgba(1.0, 0.0, 0.0, 1.0)` -\u003e rgb color with alpha (0.0-1.0)\n* `hsl(0.0, 1.0, 0.5)` -\u003e hsl color (0.0-1.0)\n* `hsla(0.0, 1.0, 0.5, 1.0)` -\u003e hsl color with alpha (0.0-1.0)\n\n### Val\n\nParses Val values, such as `1px` or `50%`.\n\n```rust\nuse bevy::ui::Val;\nuse bevy_ui_string_parser::val_string_parser;\nlet value: Option\u003cVal\u003e = val_string_parser(\"45%\");\nassert_eq!(value, Some(Val::Percent(45.0)));\n```\n\n#### Supported syntax\n\n* `auto` -\u003e `Val::Auto`\n* `12px` -\u003e `Val::Px(12.0)`\n* `12%` -\u003e `Val::Percent(12.0)`\n* `12vw` -\u003e `Val::Vw(12.0)`\n* `12vh` -\u003e `Val::Vh(12.0)`\n* `12vmin` -\u003e `Val::VMin(12.0)`\n* `12vmax` -\u003e `Val::VMax(12.0)`\n\n### Rect\n\nParses UiRect values, such as `25px 50px`.\n\nThis uses the same ordering as CSS properties like `padding` or `margin`,\nsee [mdn](https://developer.mozilla.org/en-US/docs/Web/CSS/padding) for more information.\n\n```rust\nuse bevy::ui::{UiRect, Val};\nuse bevy_ui_string_parser::rect_string_parser;\nlet rect: Option\u003cUiRect\u003e = rect_string_parser(\"50px 100px\");\nassert_eq!(rect, Some(UiRect::new(\n    Val::Px(100.0), Val::Px(100.0), Val::Px(50.0), Val::Px(50.0))));\n```\n\n#### Supported syntax\n\n* `10px 20px 30px 40px` -\u003e `top | right | bottom | left`\n* `10px 20px 10px` -\u003e `top | left and right | bottom`\n* `10px 20px` -\u003e `top and bottom | left and right`\n* `10px` -\u003e `top, right, bottom and left`\n\n### Angle\n\nParses angles into float values, such as `180deg`, returns radians.\n\n```rust\nuse bevy_ui_string_parser::angle_string_parser;\nlet angle: Option\u003cf32\u003e = angle_string_parser(\"180deg\");\nassert_eq!(angle, Some(180.0_f32.to_radians()));\n```\n\n#### Supported syntax\n\n* `180deg` -\u003e `3.14159265359`\n* `1.3rad` -\u003e `1.3`\n* `1.3` -\u003e `1.3`\n\n## Serde\n\nEach parser also provides a serde deserializer `*_serde_parser`, for example:\n\n```rust\nuse serde::Deserialize;\nuse std::f32::consts::PI;\n\n#[derive(Deserialize)]\npub struct Foo {\n    #[serde(deserialize_with = \"bevy_ui_string_parser::angle_serde_parser\")]\n    pub angle: f32,\n}\n\nlet foo: Foo = serde_json::from_str(r#\"{\"angle\": \"180deg\"}\"#).unwrap();\nassert_eq!(foo.angle, PI);\n```\n\nIt requires the optional `serde` feature.\n\n## Changelog\n\n* `v0.1.2` made serde feature optional\n* `v0.1.1` readme added\n* `v0.1.0` initial release","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattzque%2Fbevy-ui-string-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattzque%2Fbevy-ui-string-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattzque%2Fbevy-ui-string-parser/lists"}