SizeGuide (Compose)
The “Size guide” button: “Size guide” → “Calculating your size…” → “Your size: M”. A tap opens the window.
@Composablepublic fun SizeGuide( client: TryYourSize, product: String, modifier: Modifier = Modifier, variant: SizeGuideVariant = SizeGuideVariant.LINK, label: String? = null, textStyle: TextStyle = TextStyle(fontSize = 15.sp), onRecommendation: ((Recommendation) -> Unit)? = null,)Parameters
Section titled “Parameters”clientTryYourSizeRequiredYour client.
productStringRequiredYour product ID or SKU.
modifierModifierOptional= ModifierCompose modifier.
variantSizeGuideVariantOptional= SizeGuideVariant.LINKLINK (32 dp tall, 48 dp touch target) or BUTTON.
labelString?Optional= nullyour own words instead of "Size guide".
textStyleTextStyleOptional= TextStyle(fontSize = 15.sp)your text style (font, size); the colour defaults to the app theme's text colour.
onRecommendation((Recommendation) -> Unit)?Optional= nullthe shopper's recommended size, on show and on every change (sizes only).
Example
Section titled “Example”// Compose, where your "Size guide" link wasSizeGuide(tys, "SKU-123", textStyle = MaterialTheme.typography.bodyMedium) { rec -> if (rec.status == Recommendation.Status.READY && !touched) selected = rec.size}// SwiftUI, where your "Size guide" link wasSizeGuide(client: tys, product: "SKU-123") { rec in if rec.status == .ready, !touched { selectedSize = rec.size }}<SizeGuide product="SKU-123" onRecommendation={(rec) => rec.status === "ready" && !touched && setSize(rec.size)}/>const SizeGuide(product: 'SKU-123') // listen to tys.onRecommendation to preselectWas this page helpful?
Thank you. We read every answer.